Trait AuthenticationContext

Source
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§

Source

type UserId: AsRef<str> + Debug

The type used to identify users

Source

type ContextData: Debug

Additional context data type

Required Methods§

Source

fn get_user_id(&self) -> &Self::UserId

Get the user ID from the authentication context

Source

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

Get any granted scopes from the authentication context These are typically permissions granted directly via tokens

Source

fn get_context(&self) -> &Self::ContextData

Get additional context data

Source

fn is_valid(&self) -> bool

Check if this authentication context is valid (e.g., token not expired, signature valid, etc.)

Implementors§