pub struct AuthSecurity { /* private fields */ }Expand description
Main authentication security manager
Implementations§
Source§impl AuthSecurity
impl AuthSecurity
Sourcepub fn new(config: SecurityConfig) -> Self
pub fn new(config: SecurityConfig) -> Self
Create a new authentication security manager
Sourcepub fn brute_force(&self) -> &BruteForceProtector
pub fn brute_force(&self) -> &BruteForceProtector
Get the brute force protector
Sourcepub async fn check_auth_attempt(
&self,
username: &str,
ip: Option<IpAddr>,
) -> Result<()>
pub async fn check_auth_attempt( &self, username: &str, ip: Option<IpAddr>, ) -> Result<()>
Check if authentication attempt should be allowed
Returns Ok(()) if allowed, Err with reason if not
Sourcepub async fn record_auth_success(&self, username: &str, ip: Option<IpAddr>)
pub async fn record_auth_success(&self, username: &str, ip: Option<IpAddr>)
Record successful authentication
Sourcepub async fn record_auth_failure(&self, username: &str, ip: Option<IpAddr>)
pub async fn record_auth_failure(&self, username: &str, ip: Option<IpAddr>)
Record failed authentication
Sourcepub fn validate_password(&self, password: &str) -> PasswordStrengthResult
pub fn validate_password(&self, password: &str) -> PasswordStrengthResult
Validate password strength
Sourcepub fn check_password_strength(&self, password: &str) -> Result<()>
pub fn check_password_strength(&self, password: &str) -> Result<()>
Validate password strength and return Result
Sourcepub async fn log_password_change(&self, username: &str, ip: Option<IpAddr>)
pub async fn log_password_change(&self, username: &str, ip: Option<IpAddr>)
Log a password change event
Sourcepub async fn log_user_created(&self, username: &str, ip: Option<IpAddr>)
pub async fn log_user_created(&self, username: &str, ip: Option<IpAddr>)
Log a user creation event
Sourcepub async fn log_user_deleted(&self, username: &str, ip: Option<IpAddr>)
pub async fn log_user_deleted(&self, username: &str, ip: Option<IpAddr>)
Log a user deletion event
Sourcepub async fn get_audit_log(&self, count: usize) -> Option<Vec<AuditLogEntry>>
pub async fn get_audit_log(&self, count: usize) -> Option<Vec<AuditLogEntry>>
Get audit log entries (admin function)
Sourcepub async fn get_user_audit_log(
&self,
username: &str,
) -> Option<Vec<AuditLogEntry>>
pub async fn get_user_audit_log( &self, username: &str, ) -> Option<Vec<AuditLogEntry>>
Get audit log for specific user (admin function)
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 reset_rate_limit(&self, ip: &IpAddr)
pub async fn reset_rate_limit(&self, ip: &IpAddr)
Reset rate limit for an IP address (admin function)
Sourcepub fn config(&self) -> &SecurityConfig
pub fn config(&self) -> &SecurityConfig
Get the security configuration
Auto Trait Implementations§
impl Freeze for AuthSecurity
impl !RefUnwindSafe for AuthSecurity
impl Send for AuthSecurity
impl Sync for AuthSecurity
impl Unpin for AuthSecurity
impl UnsafeUnpin for AuthSecurity
impl !UnwindSafe for AuthSecurity
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