Skip to main content

AuthValidator

Trait AuthValidator 

Source
pub trait AuthValidator: Send + Sync {
    // Required method
    fn validate<'a>(
        &'a self,
        token: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<Claims, AuthError>> + Send + 'a>>;
}
Expand description

Object-safe trait for pluggable token validation.

Implementations receive the raw token string (already stripped of any scheme prefix) and return parsed Claims on success.

§Object-safety

The associated future is erased behind Pin<Box<dyn Future + Send + '_>> to keep the trait object-safe and usable with dyn AuthValidator.

Required Methods§

Source

fn validate<'a>( &'a self, token: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Claims, AuthError>> + Send + 'a>>

Validate the raw token and return Claims on success.

The token argument is the literal content of the Authorization header value (e.g. "Bearer eyJhbG...").

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§