pub trait AuthenticationContext:
Send
+ Sync
+ Debug {
type UserId: AsRef<str> + Debug;
type ContextData: Debug;
// Required methods
fn get_user_id(&self) -> &Self::UserId;
fn get_granted_scopes(&self) -> Vec<String>;
fn get_context(&self) -> &Self::ContextData;
fn is_valid(&self) -> bool;
}Expand description
A generic trait that any authentication system can implement.
This allows the role system to be integrated with any authentication mechanism, such as JWT tokens, OAuth tokens, session data, etc.
Required Associated Types§
Sourcetype ContextData: Debug
type ContextData: Debug
Additional context data type
Required Methods§
Sourcefn get_user_id(&self) -> &Self::UserId
fn get_user_id(&self) -> &Self::UserId
Get the user ID from the authentication context
Sourcefn get_granted_scopes(&self) -> Vec<String>
fn get_granted_scopes(&self) -> Vec<String>
Get any granted scopes from the authentication context These are typically permissions granted directly via tokens
Sourcefn get_context(&self) -> &Self::ContextData
fn get_context(&self) -> &Self::ContextData
Get additional context data