pub struct AuthContext {
    pub user_id: String,
    pub roles: Vec<String>,
    pub api_key: Option<String>,
    pub jwt_claims: Option<JwtClaims>,
    pub authenticated_at: DateTime<Utc>,
    pub request_id: String,
    pub metadata: HashMap<String, String>,
}Expand description
Authentication context containing validated user information
Fields§
§user_id: StringUnique user identifier
roles: Vec<String>User’s roles or permissions
api_key: Option<String>API key used for authentication (if applicable)
jwt_claims: Option<JwtClaims>JWT token claims (if JWT was used)
authenticated_at: DateTime<Utc>Timestamp when authentication occurred
request_id: StringRequest ID for tracing
metadata: HashMap<String, String>Additional metadata
Implementations§
Source§impl AuthContext
 
impl AuthContext
Sourcepub fn with_role<S: Into<String>>(self, role: S) -> Self
 
pub fn with_role<S: Into<String>>(self, role: S) -> Self
Add a role to the authentication context
Sourcepub fn with_roles<I, S>(self, roles: I) -> Self
 
pub fn with_roles<I, S>(self, roles: I) -> Self
Add multiple roles to the authentication context
Sourcepub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
 
pub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
Set the API key used for authentication
Sourcepub fn with_jwt_claims(self, claims: JwtClaims) -> Self
 
pub fn with_jwt_claims(self, claims: JwtClaims) -> Self
Set the JWT claims
Sourcepub fn with_metadata<K, V>(self, key: K, value: V) -> Self
 
pub fn with_metadata<K, V>(self, key: K, value: V) -> Self
Add metadata
Sourcepub fn has_any_role<I>(&self, roles: I) -> bool
 
pub fn has_any_role<I>(&self, roles: I) -> bool
Check if the user has any of the specified roles
Trait Implementations§
Source§impl Clone for AuthContext
 
impl Clone for AuthContext
Source§fn clone(&self) -> AuthContext
 
fn clone(&self) -> AuthContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moreAuto Trait Implementations§
impl Freeze for AuthContext
impl RefUnwindSafe for AuthContext
impl Send for AuthContext
impl Sync for AuthContext
impl Unpin for AuthContext
impl UnwindSafe for AuthContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more