-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear pending two factor tokens also from configuration #48933
Merged
nickvergessen
merged 2 commits into
master
from
clear-pending-two-factor-tokens-also-from-configuration
Nov 5, 2024
Merged
Clear pending two factor tokens also from configuration #48933
nickvergessen
merged 2 commits into
master
from
clear-pending-two-factor-tokens-also-from-configuration
Nov 5, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/backport to stable30 |
/backport to stable29 |
/backport to stable28 |
Failing CI is unrelated (Imagick and live photos). |
danxuliu
added
3. to review
Waiting for reviews
and removed
2. developing
Work in progress
labels
Oct 30, 2024
danxuliu
requested review from
ChristophWurst,
miaulalala,
nickvergessen and
st3iny
as code owners
October 30, 2024 08:01
st3iny
approved these changes
Nov 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'm not sure about possible side effects.
miaulalala
approved these changes
Nov 4, 2024
Otherwise as the tokens were removed from the database but not from the configuration the next time that the tokens were cleared the previous tokens were still got from the configuration, and trying to remove them again from the database ended in a DoesNotExistException being thrown. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
If a token was already removed from the database but not from the configuration clearing the tokens will try to remove it again from the database, which caused a DoesNotExistException to be thrown. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
nickvergessen
force-pushed
the
clear-pending-two-factor-tokens-also-from-configuration
branch
from
November 5, 2024 10:14
549d204
to
5ea5b2d
Compare
Rebasing to make CI green |
nickvergessen
deleted the
clear-pending-two-factor-tokens-also-from-configuration
branch
November 5, 2024 10:47
This was referenced Nov 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Clearing pending two factor tokens removed them from the database, but not from the configuration. Due to that, if the password was reset again, the pending tokens were got again from the configuration and tried to be cleared again from the database, which caused an exception to be thrown.
The fix is split in two commits. The first one removes the token from the configuration as well as from the database, and the second commits handles the exception thrown if a token was already removed from the database but not from the configuration, as it could be the case on an existing instance.
Note that
invalidateTokenById
does not declare any exception to be thrown, and theDoesNotExistException
comes from thePublicKeyTokenMapper
. Therefore rather than catching the exception inclearTwoFactorPending
it might be better to catch it ininvalidateTokenById
(or to transform it into another exception, as right now a database exception is being exposed to the upper layers). However I am not familiar at all with this code and any possible side effect of doing that, so I just went the safe route (specially given that this should be backported) and caught it inclearTwoFactorPending
.How to test:
LostController::setException
:Result with this pull request:
The password is reset and the login page is shown again
Result without this pull request:
token does not exist is shown below the request password form. However, if the login page is open and the new password is used it works. In the logs it can be seen that the exception was thrown by
PublicKeyTokenMapper::getTokenById
, which was called byTwoFactorAuth\Manager::clearTwoFactorPending
, so at that point the password was already changed.