pub struct AuthManager { /* private fields */ }Expand description
Authentication manager
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn new(config: AuthConfig, server_resource_id: String) -> Self
pub fn new(config: AuthConfig, server_resource_id: String) -> Self
Create a new authentication manager
Sourcepub fn constant_time_compare(a: &str, b: &str) -> bool
pub fn constant_time_compare(a: &str, b: &str) -> bool
Perform constant-time comparison of tokens This prevents timing attacks by ensuring comparison takes the same time regardless of where the first difference occurs
Sourcepub fn generate_secure_token(length: usize) -> String
pub fn generate_secure_token(length: usize) -> String
Generate a cryptographically secure token with high entropy
Generates a token with at least 128 bits of entropy using a secure random number generator. The token uses URL-safe base64 encoding.
§Arguments
length- The desired length of the token in bytes (before encoding) Minimum 16 bytes (128 bits) for security
§Returns
A URL-safe base64 encoded token string
Sourcepub fn generate_session_token() -> String
pub fn generate_session_token() -> String
Generate a secure session token
Creates a session token with 256 bits of entropy (32 bytes)
Sourcepub fn generate_api_key() -> String
pub fn generate_api_key() -> String
Generate a secure API key
Creates an API key with mixed alphanumeric characters and symbols for maximum entropy in a readable format
Sourcepub async fn authenticate(
&self,
authorization: Option<&str>,
) -> Result<AuthContext>
pub async fn authenticate( &self, authorization: Option<&str>, ) -> Result<AuthContext>
Authenticate a request with bearer token
Check if an operation is authorized
Check if resource access is authorized
Auto Trait Implementations§
impl Freeze for AuthManager
impl !RefUnwindSafe for AuthManager
impl Send for AuthManager
impl Sync for AuthManager
impl Unpin for AuthManager
impl !UnwindSafe for AuthManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more