pub struct BruteForceProtector { /* private fields */ }Expand description
Brute force protector with account lockout
Implementations§
Source§impl BruteForceProtector
impl BruteForceProtector
Sourcepub fn new(config: BruteForceConfig) -> Self
pub fn new(config: BruteForceConfig) -> Self
Create a new brute force protector
Sourcepub async fn is_user_locked(&self, username: &str) -> bool
pub async fn is_user_locked(&self, username: &str) -> bool
Check if a username is currently locked
Sourcepub async fn is_ip_locked(&self, ip: &IpAddr) -> bool
pub async fn is_ip_locked(&self, ip: &IpAddr) -> bool
Check if an IP address is currently locked
Sourcepub async fn record_failed_attempt(&self, username: &str, ip: Option<IpAddr>)
pub async fn record_failed_attempt(&self, username: &str, ip: Option<IpAddr>)
Record a failed authentication attempt
Sourcepub async fn clear_user_attempts(&self, username: &str)
pub async fn clear_user_attempts(&self, username: &str)
Clear failed attempts for a user (e.g., after successful login)
Sourcepub async fn clear_ip_attempts(&self, ip: &IpAddr)
pub async fn clear_ip_attempts(&self, ip: &IpAddr)
Clear failed attempts for an IP address
Sourcepub async fn unlock_user(&self, username: &str)
pub async fn unlock_user(&self, username: &str)
Manually unlock a user account (admin function)
Sourcepub async fn get_unlock_time(&self, username: &str) -> Option<u64>
pub async fn get_unlock_time(&self, username: &str) -> Option<u64>
Get time remaining until account unlock (in seconds)
Auto Trait Implementations§
impl Freeze for BruteForceProtector
impl !RefUnwindSafe for BruteForceProtector
impl Send for BruteForceProtector
impl Sync for BruteForceProtector
impl Unpin for BruteForceProtector
impl UnsafeUnpin for BruteForceProtector
impl !UnwindSafe for BruteForceProtector
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more