RequestAuthExt

Trait RequestAuthExt 

Source
pub trait RequestAuthExt {
    // Required methods
    fn user_session(&self) -> Option<&UserSession>;
    fn user_id(&self) -> Option<&str>;
    fn is_authenticated(&self) -> bool;
    fn has_permission(&self, permission: &str) -> bool;
    fn has_role(&self, role: &str) -> bool;
}
Expand description

Extension trait to add authentication information to requests

Required Methods§

Source

fn user_session(&self) -> Option<&UserSession>

Get the authenticated user session from the request

Source

fn user_id(&self) -> Option<&str>

Get the user ID from the authenticated session

Source

fn is_authenticated(&self) -> bool

Check if the request is authenticated

Source

fn has_permission(&self, permission: &str) -> bool

Check if the user has a specific permission

Source

fn has_role(&self, role: &str) -> bool

Check if the user has a specific role

Implementors§