Skip to main content

AuthProvider

Trait AuthProvider 

Source
pub trait AuthProvider: Send + Sync {
    // Required methods
    fn authenticate<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        req: &'life1 Request<Bytes>,
        cookies: &'life2 CookieJar,
        backend: Option<&'life3 BackendManager>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<AuthIdentity>, AuthError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn name(&self) -> &str;

    // Provided method
    fn priority(&self) -> i32 { ... }
}
Expand description

Authentication provider trait.

Providers are run in priority order (highest first) until one returns an identity.

Required Methods§

Source

fn authenticate<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, req: &'life1 Request<Bytes>, cookies: &'life2 CookieJar, backend: Option<&'life3 BackendManager>, ) -> Pin<Box<dyn Future<Output = Result<Option<AuthIdentity>, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Attempt to authenticate the request.

Returns:

  • Ok(Some(identity)) if credentials are valid
  • Ok(None) if this provider doesn’t apply
  • Err(...) if credentials are present but invalid
Source

fn name(&self) -> &str

Name for logging and debugging.

Provided Methods§

Source

fn priority(&self) -> i32

Priority for ordering (higher = checked first).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§