pub trait AuthenticationStrategy<I>: Send + Sync {
// Required method
fn authenticate<'life0, 'life1, 'async_trait>(
&'life0 self,
parts: &'life1 Parts,
) -> Pin<Box<dyn Future<Output = Result<Option<I>, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Trait for an authentication strategy.
A strategy is responsible for extracting credentials from a request and validating them to produce an identity.
Required Methods§
Sourcefn authenticate<'life0, 'life1, 'async_trait>(
&'life0 self,
parts: &'life1 Parts,
) -> Pin<Box<dyn Future<Output = Result<Option<I>, AuthError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn authenticate<'life0, 'life1, 'async_trait>(
&'life0 self,
parts: &'life1 Parts,
) -> Pin<Box<dyn Future<Output = Result<Option<I>, AuthError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Attempt to authenticate the request.
Returns:
Ok(Some(identity))if authentication was successful.Ok(None)if the strategy did not find relevant credentials (e.g., missing header).Err(AuthError)if authentication failed (e.g., invalid token, DB error).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".