1. 22 Feb, 2022 1 commit
    • Jérome Perrin's avatar
      ERP5Security,erp5: simplify EncryptedPasswordMixin.setPassword · fb979094
      Jérome Perrin authored
      For historical reasons, EncryptedPasswordMixin.setPassword was public
      and did its own security checks, this was the case since 7d0882ef (
      setPassword have to do explicit security checks…, 2007-11-12), this was
      because we wanted to support cases where user can edit the login ("Edit
      portal content" permission), but not changed the password ("Set own
      password" permission).
      
      Also, we wanted to support the case where login is edited through a view
      form, in that case we have a my_password field that is empty and we
      don't want to set the password to None in that case.
      
      For these two reasons the API to set password was very complex and
      behaving differently from other accessors: usually setSomething(None)
      just set something to None, ie. "unset" something, but for passwords it
      was not the case. Also we had to introduce _forceSetPassword method,
      which sets the password without security checks, so that it can be
      called from unrestricted code for cases where user does not have the
      permission to reset password (like in the reset password scenario).
      
      Since d1312cdb ( make edit check the security remove all useless
      security declaration on private method, 2008-05-23), edit supports
      restricted properties, so we can simplify all this and make setPassword
      a more standard accessor, ie:
       - setPassword has a security declaration, so if it is called from
        restricted python the security will apply at `__getattr__` time.
        `edit` method will also check security
       - setPassword(None) reset the password.
       - The logic to not change the password when editing in view mode is now
        `edit` responsability. ie. `login.setPassword(None)` resets, but
        `login.edit(password=None)` does not reset.
      
      This also correct some usage of the lower level API (`pw_encrypt` and
      `pw_validate`) which were never supposed to use `None`:
       - `pw_validate` was called with None when a user without password was
        trying to login, causing a TypeError that was cached by PAS and logged
        with level debug (and refusing login). Now the error is no longer raised.
       - `pw_encrypt` was called with None (but apparently only in the tests,
        when doing `user.newContent(portal_type='ERP5 Login', password=None)`)
        and this was creating a login with password `'None'` with AccessControl 2.
        With AccessControl 4 this was an Error.
      fb979094
  2. 21 Feb, 2022 13 commits
  3. 17 Feb, 2022 7 commits
  4. 16 Feb, 2022 10 commits
  5. 15 Feb, 2022 3 commits
  6. 14 Feb, 2022 1 commit
    • Vincent Pelletier's avatar
      erp5_core_test: Make testWorkflowHistoryList.TestDedup stable. · 3566c13f
      Vincent Pelletier authored
      The precise number of entries in a bucket depend on an estimation of the
      size of a pickle. The pickled data contains DateTime objects, making an
      equality test brittle:
      - DateTime's timezones are stored as strings (ex: 'GMT') whose length
        depend on Zope's timezone, which is variable
      - DateTime's time is stored as a floating-point value represented as a
        string whose length depends on the number of units and decimals are
        necessary to represent its value, both being variable (one based on when
        the test was run, the other based on clock precision and exact test
        execution timing)
      Instead, restore the originally-considered-acceptable boundary (24) and
      verify that the generated value is greater or equal to it.
      If 24 is considered too small to be acceptable, then it is a decision
      independent from the present change.
      3566c13f
  7. 13 Feb, 2022 1 commit
  8. 10 Feb, 2022 4 commits