pub struct AuthState { /* private fields */ }Expand description
Authentication middleware state. Cloning it shares the state.
Implementations§
Source§impl AuthState
impl AuthState
pub fn new(config: AuthConfig) -> Self
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if authentication is enabled
Sourcepub async fn verify_credentials(&self, username: &str, password: &str) -> bool
pub async fn verify_credentials(&self, username: &str, password: &str) -> bool
Verify credentials from an unknown client address.
Equivalent to check with no client address, returning whether the
credentials were accepted.
Sourcepub async fn check(
&self,
client: Option<IpAddr>,
username: &str,
password: &str,
) -> Verdict
pub async fn check( &self, client: Option<IpAddr>, username: &str, password: &str, ) -> Verdict
Check username and password for a request from client.
A locked-out client gets Verdict::LockedOut without its credentials being looked
at. Otherwise a failure is counted against the client, and a success clears its
failures.
Sourcepub async fn is_locked_out(&self, username: &str) -> bool
pub async fn is_locked_out(&self, username: &str) -> bool
Whether username is locked out when connecting from an unknown address.
Sourcepub async fn is_locked_out_from(
&self,
client: Option<IpAddr>,
username: &str,
) -> bool
pub async fn is_locked_out_from( &self, client: Option<IpAddr>, username: &str, ) -> bool
Whether username is locked out when connecting from client.
Sourcepub async fn cleanup_expired_attempts(&self)
pub async fn cleanup_expired_attempts(&self)
Drop failure records whose lockout has expired, and expired verifications.
Sourcepub fn tracked_clients(&self) -> usize
pub fn tracked_clients(&self) -> usize
The number of clients with failure records (for tests and monitoring).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AuthState
impl !UnwindSafe for AuthState
impl Freeze for AuthState
impl Send for AuthState
impl Sync for AuthState
impl Unpin for AuthState
impl UnsafeUnpin for AuthState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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