feat(auth): Lock accounts after repeated failed logins#105
Merged
Conversation
LoginAttemptListener counts consecutive wrong-password logins per account and locks the account at the threshold (5 by default, learndev.lockout.max-attempts): users.is_locked already maps to Spring Security accountLocked, so a locked account is rejected even with the right password. A successful login resets the counter and finally stamps last_login_at. Failures for unknown usernames change nothing observable (no enumeration). Two unlock paths, both audited: the admin accounts page gains a Locked status and an Unlock action, and completing a password reset clears the lock too, since it proves control of the mailbox. AccountLockoutFlowTest drives it end to end with a lowered threshold: three strikes lock the account, the correct password is then rejected, the admin unlock clears lock and counter, and the next login succeeds and stamps the login time.
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.
This PR adds a user account lockout feature that activates after 3 failed login attempts.
LoginAttemptListener:users.is_lockedalready maps to Spring SecurityaccountLocked, so a locked account is rejected even with the right password.last_login_at.AccountLockoutFlowTesttests the flow end-to-end with a lowered threshold:This is part 2 of 2 in a stack made with GitButler: