Skip to main content

AuthBackend

Trait AuthBackend 

Source
pub trait AuthBackend: Send + Sync {
    // Required method
    fn verify<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<AuthResult, AuthError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn record_traffic<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _user_id: &'life1 str,
        _bytes: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for authentication backends.

Implementations must be thread-safe (Send + Sync) as they may be called concurrently from multiple connections.

Required Methods§

Source

fn verify<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<AuthResult, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Verify a password hash.

§Arguments
  • hash - The SHA224 hex-encoded hash of the password
§Returns
  • Ok(AuthResult) - Authentication successful
  • Err(AuthError) - Authentication failed

Provided Methods§

Source

fn record_traffic<'life0, 'life1, 'async_trait>( &'life0 self, _user_id: &'life1 str, _bytes: u64, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Optional: Record traffic usage for a user.

Default implementation does nothing.

Implementations on Foreign Types§

Source§

impl<A: AuthBackend + ?Sized> AuthBackend for Box<A>

Blanket implementation for Box<A> where A: AuthBackend.

Source§

fn verify<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<AuthResult, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn record_traffic<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 str, bytes: u64, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<A: AuthBackend + ?Sized> AuthBackend for Arc<A>

Blanket implementation for Arc<A> where A: AuthBackend.

This allows passing Arc<AuthBackend> directly to functions expecting impl AuthBackend.

Source§

fn verify<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<AuthResult, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn record_traffic<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 str, bytes: u64, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§