Repository navigation
Issue a new password reset token on each request - #14655
Open
MitchDrage wants to merge 1 commit into
Open
MitchDrage wants to merge 1 commit into
MitchDrage wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or 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
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.
Description
This PR fixes a second forgot-password request silently doing nothing while the first token is still valid.
user.password.reset.email.cooldown(seconds, default 300, 0 disables). Requests for the same user within the cooldown send no email and are logged at INFO. The cooldown is claimed before the email is sent and kept if the send fails, so a mail outage does not remove the limit. It is best effort: requests arriving at the same instant can each pass the check. A per-userGlobalLockwould close that gap, but each held lock opens its own database connection outside the pool. The lock would be held for the whole SMTP send on an unauthenticated endpoint, so I chose the cooldown claim instead.SMTPMailSender.trySendMail, which returns whether the SMTP server accepted the message.sendMaillogs and swallows every failure, so the reset code cannot tell when an email never went out. Saving a new token after a failed send would invalidate the user's working link with nothing delivered. The token is now saved only aftertrySendMailreturns true.sendMailkeeps itsvoidsignature and now callstrySendMail, ignoring the result. The send logic, logging and exception handling are unchanged. Its other callers (AlertManagerImpl,ProjectManagerImpl,QuotaAlertManagerImpl,UsageAlertManagerImpl) need no changes, and their existing tests pass.en.jsonis updated; other locales are left for translators.The wait between reset emails was previously tied to
user.password.reset.ttl. It is now set separately byuser.password.reset.email.cooldown. Since anyone can request a reset for a known username, repeated requests can replace a user's pending link once per cooldown. The 300-second default keeps that to a nuisance, and the user can always request a fresh link.Fixes: #13604
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
SMTPMailSenderTestcoverstrySendMailreturning true and false. The existing tests for the othersendMailcallers (alerts, quota, usage, projects) pass unchanged.How did you try to break this feature and the system with this change?