Authenticatable

Trait Authenticatable 

Source
pub trait Authenticatable:
    Send
    + Sync
    + Clone {
    type Id: Clone + Send + Sync + Debug + PartialEq;
    type Credentials: Send + Sync;

    // Required methods
    fn id(&self) -> &Self::Id;
    fn username(&self) -> &str;
    fn verify_credentials<'life0, 'life1, 'async_trait>(
        &'life0 self,
        credentials: &'life1 Self::Credentials,
    ) -> Pin<Box<dyn Future<Output = AuthResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn is_active(&self) -> bool { ... }
    fn is_locked(&self) -> bool { ... }
    fn roles(&self) -> Vec<String> { ... }
    fn permissions(&self) -> Vec<String> { ... }
    fn additional_data(&self) -> HashMap<String, Value> { ... }
}
Expand description

Trait for types that can be authenticated

Required Associated Types§

Required Methods§

Source

fn id(&self) -> &Self::Id

Get the user’s unique identifier

Source

fn username(&self) -> &str

Get the user’s username/email for authentication

Source

fn verify_credentials<'life0, 'life1, 'async_trait>( &'life0 self, credentials: &'life1 Self::Credentials, ) -> Pin<Box<dyn Future<Output = AuthResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Verify credentials against this user

Provided Methods§

Source

fn is_active(&self) -> bool

Check if the user account is active

Source

fn is_locked(&self) -> bool

Check if the user account is locked

Source

fn roles(&self) -> Vec<String>

Get the user’s role names

Source

fn permissions(&self) -> Vec<String>

Get the user’s direct permissions

Source

fn additional_data(&self) -> HashMap<String, Value>

Get additional user data for token/session storage

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§