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§
Sourcefn 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,
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§
Sourcefn permissions(&self) -> Vec<String>
fn permissions(&self) -> Vec<String>
Get the user’s direct permissions
Sourcefn additional_data(&self) -> HashMap<String, Value>
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.