Review main Merged

63385[FEATURE] Reset password for backend users

Benni Mack CR +2 V +2 Expert +1566 −10 updated 03/06/20, 20:45

Commit message

This feature adds a link on TYPO3 Backend's login form
to reset a backend users' password if the user has forgotten the password.

Key changes:
* Only enabled for backend users with an email address and a password set
* Enabled by default but can be disabled completely
* Optionally only works for non-admins via TYPO3_CONF_VARS
* Only send out emails to users within the system, but no information disclosure
* If multiple valid users have the same email address, a different email is sent out
* TCA be_users.email is not set to eval=email (due to backwards-compatibility)
* Password resets are only valid for 2 hours (non-configurable)
* Not extensible for third-party authentication methods yet
* Rate limiting is enabled per email address for 3 attempts per 30mins (non-configurable)
* When logging in, all previous tokens are removed
* When requesting multiple resets, only the last email is valid
* A CLI command "backend:resetpassword $backendUrl $emailAddress" sends out an email as well from admins
* Admins can trigger a password reset for users in the BE User module

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Andreas Kienast +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Andreas Kienast +1
    • TYPO3com +1 CI

Issues 1

Files 32

Show 12 more files

Review log 3450

Show 1725 earlier messages
  1. Benni Mack uploaded patch set 1 02/22/20, 23:22

  2. TYPO3com voted on patch set 1 V +1 02/22/20, 23:43 Completed build in 21m 40s on Sat, 22 Feb, 11:43 PM Test Summary: 71586 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-525

  3. Helmut Hummel commented on patch set 1 02/23/20, 11:36

    I like the general approach for its simplicity. Only the bare minimum is done to achieve what is needed. I have some remarks regarding the current implementation, which I added as inline code comments. Some general remarks: It might be useful to make it possible to disable this feature by configuration, because there are quite some szenarios, where the TYPO3 backend login isn't based on local passwords. In such cases (e.g. LDAP login), it will be confusing to be able to trigger a local password reset workflow, which basically does nothing. Emails are an inherently insecure medium to transport sensitive information. I would further decrease the time the token is valid (or at least make it configurable as well, defaulting to 15min or so) Knowing a valid email address of a backend user enables an attacker to send out an arbitrary amount of recovery mails. A rate limiting API (can't find the forge ticket for handling this) or at least a hook to enable (a custom) one could be helpful as well.

    PasswordReset.php:53

    I can't see where it is checked for a non empty email here.

    PasswordReset.php:164

    I can't see how this improves the security of the token (with the current implementation) over it just being a random string. In case I'm correct, I'd just make $randomString the token.

    PasswordReset.php:199

    Whether the token is expired or not is checked against a timestamp value sent as GET argument. Thus the token can never expire :)

    PasswordReset.php:208

    Edge case szenario: After the recovery link is generated, the same email address is added to another user. Possible ways to handle that szenario: * Count for user rows with given email hash here as well and fail if !== 1 * Change TCA to make email unique (validate for uniquness in data handler * Add the uid to the identity

    PasswordReset.php:216

    Any reason the signature of this method returns an int instead of the user array or null? The latter seems more logical to me
  4. Helmut Hummel commented on patch set 1 02/23/20, 11:37

    > Password resets are only valid for 4 hours (non-configurable) Maybe max 4h, but could be configurable between 10min and 4h?
  5. Andreas Kienast commented on patch set 1 CR -1 02/23/20, 14:52

    on it now
  6. Andreas Kienast commented on patch set 1 02/23/20, 15:24

    PasswordReset.php:53 Reply

    Ack

    PasswordReset.php:164 Reply Unresolved

    Perhaps some extra entropy, I guess. Arguably this may be used as $additionalSecret in GU::hmac().

    PasswordReset.php:199 Reply

    Ack

    PasswordReset.php:208 Reply Unresolved

    I'd prefer the uid-based solution. Changing the TCA may be a breaking change at this point.

    PasswordReset.php:216 Reply Unresolved

    I agree at this point, I just wonder why we "double check the user" in resetPassword(). If there is no special reason, I'm fine with changing this method to return an ?array.
  7. Andreas Kienast uploaded patch set 2 02/23/20, 16:11

  8. TYPO3com voted on patch set 2 V -1 02/23/20, 16:11 Completed build in 23s on Sun, 23 Feb, 04:11 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-572

  9. Benni Mack uploaded patch set 3 02/24/20, 10:31

  10. TYPO3com voted on patch set 3 V +1 02/24/20, 10:49 Completed build in 18m 09s on Mon, 24 Feb, 10:49 AM Test Summary: 71589 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-609

  11. Benni Mack uploaded patch set 4 03/04/20, 07:14

  12. TYPO3com voted on patch set 4 V +1 03/04/20, 07:28 Completed build in 14m 11s on Wed, 4 Mar, 07:28 AM Test Summary: 72117 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-962

  13. Benni Mack uploaded patch set 5 03/06/20, 10:19

  14. TYPO3com voted on patch set 5 V +1 03/06/20, 10:33 Completed build in 13m 27s on Fri, 6 Mar, 10:33 AM Test Summary: 72072 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1012

  15. Benni Mack uploaded patch set 6 03/06/20, 12:58

  16. TYPO3com voted on patch set 6 V -1 03/06/20, 13:09 Completed build in 10m 27s on Fri, 6 Mar, 01:09 PM Test Summary: 4 of 72580 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1023

  17. Benni Mack uploaded patch set 7 03/06/20, 13:31

  18. Benni Mack uploaded patch set 8 03/06/20, 13:35

  19. TYPO3com voted on patch set 7 V -1 03/06/20, 13:43 Completed build in 11m 04s on Fri, 6 Mar, 01:43 PM Test Summary: 4 of 72580 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1028

  20. Roland Golla commented on patch set 8 V -1 03/06/20, 13:46

    Can not load backend path /typo3 error TYPO3 exception (1/1) #1476050190 TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException Unable to generate a URL for the named route "password_forget" because this route was not found.
  21. Benni Mack commented on patch set 8 03/06/20, 13:47

    > Patch Set 8: Verified-1 > > Can not load backend path /typo3 > > error TYPO3 exception > (1/1) #1476050190 TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException > Unable to generate a URL for the named route "password_forget" because this route was not found. You need to flush the system caches, as we now have a new route.
  22. Andreas Kienast commented on patch set 8 V -1 03/06/20, 13:48

    I get the following error after I set a new password: Argument 3 passed to TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate() must be of the type array or null, string given, called in /typo3/sysext/fluid/Classes/ViewHelpers/TranslateViewHelper.php on line 165
  23. TYPO3com voted on patch set 8 V -1 03/06/20, 13:50 Completed build in 14m 14s on Fri, 6 Mar, 01:50 PM Test Summary: 4 of 72580 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1030

  24. Andreas Kienast uploaded patch set 9 03/06/20, 14:23

  25. Andreas Kienast uploaded patch set 10 03/06/20, 14:26

  1. TYPO3com voted on patch set 9 V -1 03/06/20, 14:37 Completed build in 14m 26s on Fri, 6 Mar, 02:37 PM Test Summary: 1 of 71964 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1032

  2. TYPO3com voted on patch set 10 V -1 03/06/20, 14:39 Completed build in 12m 58s on Fri, 6 Mar, 02:39 PM Test Summary: 2 of 72577 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1033

  3. Andreas Kienast uploaded patch set 11 03/06/20, 14:43

  4. Andreas Kienast commented on patch set 11 CR -1 03/06/20, 14:49

    still on it
  5. TYPO3com voted on patch set 11 V -1 03/06/20, 14:55 Completed build in 12m 06s on Fri, 6 Mar, 02:55 PM Test Summary: 72093 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1035

  6. Andreas Kienast commented on patch set 11 03/06/20, 15:01

    ResetPasswordCommand.php:103 Unresolved

    This fails if I use "foo.com/typo3" instead of "foo.com/typo3/"

    ResetPasswordCommand.php:141 Unresolved

    dirname(Environment::getCurrentScript(), 4)
  7. Andreas Kienast uploaded patch set 12 03/06/20, 15:01

  8. Andreas Kienast uploaded patch set 13 03/06/20, 15:07

  9. TYPO3com voted on patch set 12 V -1 03/06/20, 15:11 Completed build in 10m 39s on Fri, 6 Mar, 03:11 PM Test Summary: 72093 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1036

  10. TYPO3com voted on patch set 12 V +1 03/06/20, 15:13 Completed build in 23m 07s on Fri, 6 Mar, 03:13 PM Test Summary: 72093 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1036

  11. TYPO3com voted on patch set 13 V +1 03/06/20, 15:19 Completed build in 11m 48s on Fri, 6 Mar, 03:19 PM Test Summary: 72091 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1037

  12. Andreas Kienast commented on patch set 13 CR -1 03/06/20, 15:30

    IndexListRow.html:80 Unresolved

    This label doesn't exist
  13. Andreas Kienast uploaded patch set 14 03/06/20, 15:41

  14. TYPO3com voted on patch set 14 V +1 03/06/20, 15:53 Completed build in 11m 04s on Fri, 6 Mar, 03:52 PM Test Summary: 72093 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1040

  15. Andreas Kienast voted on patch set 14 V +1 CR +1 03/06/20, 16:02

  16. Andreas Kienast rebased onto patch set 15 03/06/20, 16:30

  17. Andreas Kienast commented on patch set 15 V +1 CR +1 03/06/20, 16:32

    I just did a rebase due to new phpstan configs
  18. TYPO3com voted on patch set 15 V +1 03/06/20, 16:41 Completed build in 10m 57s on Fri, 6 Mar, 04:41 PM Test Summary: 72093 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1045

  19. Georg Ringer commented on patch set 15 03/06/20, 19:24

    PasswordReset.php:97

    should it also check if there is an email addr filled?

    ResetPasswordCommand.php:46

    can't we use the 1st site config domain which is not / as fallback

    Routes.php:46

    strange that this and next is not commented
  20. Benni Mack commented on patch set 15 03/06/20, 19:26

    PasswordReset.php:97 Reply Unresolved

    getPreparedQueryBuilder() does that already

    ResetPasswordCommand.php:46 Reply Unresolved

    Tried that at the beginning, that proved to be _not_ working. Mainly because I had www.example.com/subpage/ as the first site, so the "guessing" just went south big time.

    Routes.php:46 Reply Unresolved

    :D
  21. Georg Ringer voted on patch set 15 CR +1 03/06/20, 19:47

  22. Georg Ringer commented on patch set 15 CR -1 03/06/20, 20:01

    locallang_reset_password.xlf:13 Unresolved

    this sounds very strange

    ResetRequested.html:3 Unresolved

    this looks strange. gitlab sends such mails ------- Hello, Georg Ringer! Someone, hopefully you, has requested to reset the password for your GitLab account on xxxxxx. If you did not perform this request, you can safely ignore this email. Otherwise, click the link below to complete the process.
  23. Georg Ringer commented on patch set 15 V +1 CR +1 03/06/20, 20:08

    I remove my -1 for text as this can be improved later on, works great for me. thx!
  24. Georg Ringer voted on patch set 15 V +2 CR +2 03/06/20, 20:40

  25. Georg Ringer merged patch set 16 03/06/20, 20:45