pub struct LoginAttemptTracker { /* private fields */ }Expand description
In-memory brute-force / account lockout tracker.
Tracks consecutive failed sign-in attempts per key (typically an email
address). After max_failures failed attempts within window, the
account is considered locked until the window elapses.
Successful sign-ins reset the failure counter for that key.
The tracker is Clone + Send + Sync — share a single instance across the
application via Arc or embed it directly in service state.
Implementations§
Source§impl LoginAttemptTracker
impl LoginAttemptTracker
pub fn new(cfg: LockoutConfig) -> Self
Sourcepub fn record_failure(&self, key: &str)
pub fn record_failure(&self, key: &str)
Record a failed attempt. Call this when credentials are wrong.
Sourcepub fn record_success(&self, key: &str)
pub fn record_success(&self, key: &str)
Reset the failure counter on successful sign-in.
Trait Implementations§
Source§impl Clone for LoginAttemptTracker
impl Clone for LoginAttemptTracker
Source§fn clone(&self) -> LoginAttemptTracker
fn clone(&self) -> LoginAttemptTracker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LoginAttemptTracker
impl RefUnwindSafe for LoginAttemptTracker
impl Send for LoginAttemptTracker
impl Sync for LoginAttemptTracker
impl Unpin for LoginAttemptTracker
impl UnsafeUnpin for LoginAttemptTracker
impl UnwindSafe for LoginAttemptTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more