pub struct AuthContext {
pub user_id: Option<UserId>,
pub username: Option<String>,
pub scopes: Vec<TokenScope>,
pub authenticated: bool,
pub client_ip: String,
}Expand description
Authentication context extracted from request.
Fields§
§user_id: Option<UserId>User ID if authenticated.
username: Option<String>Username if authenticated.
scopes: Vec<TokenScope>Token scopes if authenticated via token.
authenticated: boolWhether the user is authenticated.
client_ip: StringClient IP for rate limiting.
Implementations§
Source§impl AuthContext
impl AuthContext
Sourcepub fn authenticated(
user_id: UserId,
username: String,
scopes: Vec<TokenScope>,
client_ip: String,
) -> Self
pub fn authenticated( user_id: UserId, username: String, scopes: Vec<TokenScope>, client_ip: String, ) -> Self
Create an authenticated context.
Sourcepub fn has_scope(&self, scope: TokenScope) -> bool
pub fn has_scope(&self, scope: TokenScope) -> bool
Check if a scope is granted.
Sourcepub fn rate_limit_key(&self) -> String
pub fn rate_limit_key(&self) -> String
Get the rate limit key (user ID or IP).
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 (const: unstable) · 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 UnsafeUnpin 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