Authenticator

Trait Authenticator 

Source
pub trait Authenticator {
    // Required method
    fn authenticate(
        &mut self,
    ) -> impl Future<Output = AuthResult<UserProfile>> + Send;

    // Provided methods
    fn verify(
        &self,
        token: &str,
    ) -> impl Future<Output = AuthResult<UserProfile>> + Send { ... }
    fn logout(&self, token: &str) -> impl Future<Output = AuthResult<()>> + Send { ... }
}
Expand description

Core authentication trait

All authentication providers must implement this trait

Required Methods§

Source

fn authenticate( &mut self, ) -> impl Future<Output = AuthResult<UserProfile>> + Send

Authenticate a user and return their profile

§Arguments
  • event_bus: Optional event bus for emitting auth events
§Returns
  • Ok(UserProfile) on success
  • Err(AuthError) on failure

Provided Methods§

Source

fn verify( &self, token: &str, ) -> impl Future<Output = AuthResult<UserProfile>> + Send

Verify if a token is still valid

§Arguments
  • token: The access token to verify
§Returns
  • Ok(UserProfile) if token is valid
  • Err(AuthError) if token is invalid or expired
Source

fn logout(&self, token: &str) -> impl Future<Output = AuthResult<()>> + Send

Logout and invalidate the token

§Arguments
  • token: The access token to invalidate

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§