Review main Merged

77424[FEATURE] Add password policy validation for TCA type=password

Torben Hansen CR +2 V +2 Hard +248 −8 updated 03/23/23, 05:29

Commit message

It is now possible to assign a password policy to TCA fields of the
type `password`. For configured fields, the password policy validator
will be used in `DataHandler` to ensure, that the new password complies
with the configured password policy.

The TCA field `password` for the tables `be_users` and `fe_users`
now use the password policy configured in
`$GLOBALS['TYPO3_CONF_VARS']['FE']['passwordPolicy']` (fe_users) or
`$GLOBALS['TYPO3_CONF_VARS']['BE']['passwordPolicy']` (be_users)
by default.

If a password does not comply with the configured password policy,
the password is not saved, a warning is logged to `sys_log` and
a flash message is shown.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 10

Review log 2839

Show 1014 earlier messages
  1. Torben Hansen uploaded patch set 1 01/17/23, 16:40

  2. core-ci voted on patch set 1 V +1 01/17/23, 16:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35982

  3. Stefan Bürk updated the commit message in patch set 2 V +1 01/17/23, 20:56

  4. Stefan Bürk updated the commit message in patch set 3 01/17/23, 20:57

  5. Stefan Bürk commented on patch set 3 01/17/23, 21:11

    DataHandler.php:1849

    Maybe we should make the "mode" also configurable for `type=password` with policy - that way, it could be used by custom extension to tell if they need a FE or a BE hashed password. With this condition everything is BE hashed beside `fe_users` table - not sure, eventually a dedicated change ? Just wondering while reading that change - I think this would make sense .... Would not make sense if someone uses this TCA field type with FE poliy -- but get's be hased passwords. Thinking more about this, this may be suitable as dedicated change. Some other opinions on this ?
  6. core-ci voted on patch set 2 V +1 01/17/23, 21:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36029

  7. core-ci voted on patch set 3 V +1 01/17/23, 21:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36030

  8. Stefan Bürk voted on patch set 3 V +1 01/17/23, 21:21

  9. Georg Ringer commented on patch set 3 01/17/23, 21:28

    DataHandler.php:1849 Reply

    if not configurable I would turn it around, be_users => always BE, rest is FE but configuration would be nicer
  10. Torben Hansen commented on patch set 3 01/18/23, 12:13

    DataHandler.php:1849 Reply

    I agree, that a configuration option for the mode (which overrides the current `$mode` evaluation) would be nice in a dedicated change. If we change the current evaluation as Georg suggested, this would be a breaking change, if FE password hashing algorithm != BE password hashing algorithm, so I suggest to keep this as it is for now.
  11. Oli Bartsch commented on patch set 3 01/18/23, 16:13

    password-element.ts:33

    Should we use this.querySelector() instead?

    password-element.ts:34

    This should ne a direct child of the "element", right?

    PasswordElement.php:32

    I would like to omit class properties in such classes. We should just pass the instance to renderPasswordPolicyRequirements() - if initialized at all.

    PasswordElement.php:220

    This check is duplicated.

    DataHandler.php:1857

    This operation might not be necessary, depending on the isValidPassword() check below.

    DataHandler.php:1868

    Shouldn't we use the already available functionality `printLogErrorMessages()`, which collects the errors and prints them as flash message?

    be_users.php:56

    Let's avoid introducing new dependencies to $GLOBALS, especially in TCA. We recently removed this in some other places, e.g. https://review.typo3.org/c/Packages/TYPO3.CMS/+/75916/17/typo3/sysext/core/Documentation/Changelog/12.0/Feature-98479-NewTCATypeFile.rst#82

    Feature-97389-AddPasswordPolicyValidationForTCATypepassword.rst:1

    Actually we always try to make the rst a bit less technical. Currently the RST completely duplicates the commit message. Could this please be improved?
  12. Torben Hansen uploaded patch set 4 V +1 01/21/23, 17:41

  13. Torben Hansen commented on patch set 3 01/21/23, 17:41

    password-element.ts:33 Reply

    Done

    password-element.ts:34 Reply

    Ack

    PasswordElement.php:32 Reply

    Done

    PasswordElement.php:220 Reply

    Agree, the `$passwordPolicy` is typecasted in `GU::implodeAttributes()`.

    DataHandler.php:1857 Reply

    Done, moved the whole password hashing part below the password policy check

    DataHandler.php:1868 Reply

    No, `printLogErrorMessages()` collects error messages from `sys_log`. This does not make sense in case of password policies, since it would require to log all failed password policy validators to `sys_log`.

    be_users.php:56 Reply

    The password policy for the field `password` in `be_users` and `fe_users` is actually a global setting, so I think this is a valid usage of `$GLOBALS` in TCA here. If we would not use `$GLOBALS` here, we have to hardcode the evaluation of the global configured password policy in both `DataHandler` and `PasswordElement`, if the field is `password` and the table is either `fe_users` or `be_users`. This seems not really good to me and would also produce duplicate code.

    Feature-97389-AddPasswordPolicyValidationForTCATypepassword.rst:1 Reply

    Updated the RST to make the "Impact" section less technical.
  14. core-ci voted on patch set 4 V +1 01/21/23, 17:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36413

  1. Benni Mack commented on patch set 4 01/23/23, 14:36

    DataHandler.php:1864

    please no flashMessages here, anymore.use "->log()" and "->printLogErrorMessages()" instead.
  2. Torben Hansen uploaded patch set 5 V +1 01/26/23, 07:31

  3. Torben Hansen commented on patch set 5 01/26/23, 07:33

    DataHandler.php:1849 Reply

    Configuration option for mode should be made in a follow up patch.

    DataHandler.php:1864 Reply

    Done
  4. core-ci voted on patch set 5 V -1 01/26/23, 07:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36638

  5. Torben Hansen uploaded patch set 6 V -1 01/26/23, 07:48

  6. core-ci voted on patch set 6 V +1 01/26/23, 07:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36639

  7. Torben Hansen rebased onto patch set 7 V +1 02/07/23, 18:19

  8. core-ci voted on patch set 7 V +1 02/07/23, 18:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37307

  9. Benni Mack commented on patch set 8 V +1 02/08/23, 07:49

    Published edit on patch set 7.
  10. core-ci voted on patch set 8 V +1 02/08/23, 08:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37328

  11. Georg Ringer commented on patch set 8 V +1 CR +1 02/08/23, 08:20

    in a next step, persisting should be avoided if the password doesn't meet the criteria - is that possible to validate password with ajax endpoint?
  12. Benni Mack commented on patch set 8 02/08/23, 09:48

    DataHandler.php:1881

    what is 95?
  13. Torben Hansen commented on patch set 8 02/08/23, 10:09

    Reply

    Yes, this will be part of https://forge.typo3.org/issues/97393

    DataHandler.php:1881 Reply

    A new `$details_nr`. I was actually unsure which number to use here and thought it would be good to have a unique number for those kind of log entries, so they can be filtered/excluded from queries if required. I'm also fine using either `0` or `-1`, if this is better.
  14. Torben Hansen rebased onto patch set 9 CR +1 V +1 03/12/23, 17:17

  15. core-ci voted on patch set 9 V +1 03/12/23, 17:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38833

  16. Torben Hansen uploaded patch set 10 V +1 03/12/23, 17:49

  17. Torben Hansen commented on patch set 10 03/12/23, 17:49

    DataHandler.php:1881 Reply

    Changed this it `-1`
  18. core-ci voted on patch set 10 V +1 03/12/23, 18:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38839

  19. Benni Mack voted on patch set 10 CR +1 03/14/23, 20:59

  20. Georg Ringer voted on patch set 10 V +1 CR +1 03/15/23, 06:48

  21. Markus Klein updated the commit message in patch set 11 CR +1 V +1 03/16/23, 09:54

  22. core-ci voted on patch set 11 V +1 03/16/23, 10:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39047

  23. Benni Mack commented on patch set 11 V +1 CR +1 03/22/23, 16:53

    In general this is OK, however we should adapt this feature after feature freeze to validate on-the-fly with JS so the user knows what he/she entered
  24. Georg Ringer voted on patch set 11 V +2 CR +2 03/23/23, 05:29

  25. Georg Ringer merged patch set 12 03/23/23, 05:29