pub struct AuthMiddleware { /* private fields */ }Expand description
Authentication Middleware
Validates incoming requests for authentication requirements. Acts as the second layer in the security middleware pipeline.
Implementations§
Source§impl AuthMiddleware
impl AuthMiddleware
Sourcepub fn from_config(config: AuthConfig) -> Self
pub fn from_config(config: AuthConfig) -> Self
Create a new authentication middleware from configuration
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create middleware with permissive settings (authentication optional)
Sourcepub fn strict() -> Self
pub fn strict() -> Self
Create middleware with strict settings (authentication required, short expiry)
Sourcepub fn validate_request(&self, req: &AuthRequest) -> Result<AuthenticatedUser>
pub fn validate_request(&self, req: &AuthRequest) -> Result<AuthenticatedUser>
Validate authentication in a request
Performs validation checks in order:
- Extract token from Authorization header
- Validate token signature (if signing key configured)
- Check token expiry (exp claim)
- Validate issuer/audience claims (if configured)
- Extract required claims (sub)
- Extract optional claims (scope, aud, iss)
Returns AuthenticatedUser if valid, Err if any check fails.
Sourcepub const fn config(&self) -> &AuthConfig
pub const fn config(&self) -> &AuthConfig
Get the underlying configuration
Trait Implementations§
Source§impl Clone for AuthMiddleware
impl Clone for AuthMiddleware
Source§fn clone(&self) -> AuthMiddleware
fn clone(&self) -> AuthMiddleware
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 AuthMiddleware
impl RefUnwindSafe for AuthMiddleware
impl Send for AuthMiddleware
impl Sync for AuthMiddleware
impl Unpin for AuthMiddleware
impl UnsafeUnpin for AuthMiddleware
impl UnwindSafe for AuthMiddleware
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