Open
Conversation
Implements in-memory login attempt throttling that tracks failed attempts per identity and temporarily locks accounts after exceeding configurable thresholds. New config options under selfservice.flows.login.throttle: - max_attempts: max failures before lockout (default: 0 = disabled) - window: time window for counting failures (default: 5m) - lockout_duration: how long account stays locked (default: 15m) When throttling is enabled and an identity exceeds max_attempts within the window, subsequent login attempts return HTTP 429 until the lockout expires. Successful logins reset the counter. Relates to ory#3037
Author
Test Results |
Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
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.
Adds configurable login throttling to protect against brute force credential attacks. This has been a long-requested feature (#3037, #654).
What it does
Tracks failed login attempts per identity in memory and temporarily locks out accounts that exceed a configurable threshold. Config looks like:
When disabled (max_attempts: 0, the default), behavior is unchanged from today.
How it works
throttle.Limiterinselfservice/flow/login/throttle/does the actual tracking with a sliding window approachCleanup()method prevents unbounded memory growthdriver/configfor the three settingsExtractIdentityIDhelper inx/err.goto pull identity IDs from wrapped errorsLimitations / future work
This is an in-memory implementation, so it won't persist across restarts and doesn't share state across multiple kratos instances. A database-backed implementation (as outlined in the original issue) would be the next step, but this gets the core logic and config in place.
Tests
Relates to #3037