Problem/Motivation
For an account that still has to set up TFA, a one-time login link that core refuses (expired, already used or otherwise not valid) uses up one of the allowed skips. Once they are used up, the user can no longer log in until an administrator resets the counter. TfaOneTimeLoginEventSubscriber::redirectOneTimeLogin() calls canLoginWithoutTfa() and hasSkipped() before it checks the timestamp and hash of the link. The branch for login plugins also runs before that check, so an invalid link can show "You have logged in on a trusted system." For an account that never logged in, the subscriber does not apply the time out at all, while core refuses such a link once it reached the time out. The subscriber was added in #3392427: Use an EventSubscriber to process one time login links.
Steps to reproduce
- Install TFA 2.x-dev (f426ec7) on Drupal 11.4.13 or 10.6.22. Enable TFA with a validation plugin, require it for authenticated users and keep "Skip Validation" at 3.
- As a user without TFA set up, request a password reset and open the link from the email. The message says "You have 2 attempts left."
- Log out and open the same link again. The page says that the link has either been used or is no longer valid.
- Log in with the password. The message says "You have 0 attempts left." instead of "You have 1 attempt left."
Proposed resolution
Move the branches for accounts without TFA set up and for login plugins below the existing timestamp and hash checks, as TfaUserControllerBase::doResetPassLogin() in 8.x-1.x and UserController::resetPassLogin() in core do. In that check, also refuse a link that reached the time out when the account never logged in, as core does. The subscriber then records a skip or a trusted login only for a link that core accepts.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork tfa-3642275
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments