pub struct AuthManager { /* private fields */ }
Expand description
Authentication manager
Implementations§
Source§impl AuthManager
impl AuthManager
pub fn new(config: AuthConfig) -> Result<Self>
Sourcepub async fn create_jwt_token(
&self,
user_id: &str,
name: &str,
role: &str,
permissions: Vec<String>,
) -> Result<String>
pub async fn create_jwt_token( &self, user_id: &str, name: &str, role: &str, permissions: Vec<String>, ) -> Result<String>
Create a new JWT token for a user
Sourcepub async fn validate_jwt_token(&self, token: &str) -> Result<Claims>
pub async fn validate_jwt_token(&self, token: &str) -> Result<Claims>
Validate and decode JWT token
Sourcepub async fn create_api_key(
&self,
name: &str,
role: &str,
permissions: Vec<String>,
expires_in_days: Option<u32>,
) -> Result<(String, ApiKey)>
pub async fn create_api_key( &self, name: &str, role: &str, permissions: Vec<String>, expires_in_days: Option<u32>, ) -> Result<(String, ApiKey)>
Create a new API key
Sourcepub async fn validate_api_key(&self, key: &str) -> Result<ApiKey>
pub async fn validate_api_key(&self, key: &str) -> Result<ApiKey>
Validate API key
Sourcepub async fn revoke_api_key(&self, key_id: &str) -> Result<()>
pub async fn revoke_api_key(&self, key_id: &str) -> Result<()>
Revoke API key
Sourcepub async fn get_active_sessions(&self) -> Vec<UserSession>
pub async fn get_active_sessions(&self) -> Vec<UserSession>
Get active sessions
Sourcepub async fn revoke_session(&self, session_id: &str) -> Result<()>
pub async fn revoke_session(&self, session_id: &str) -> Result<()>
Revoke user session
Sourcepub async fn cleanup_expired_sessions(&self) -> Result<usize>
pub async fn cleanup_expired_sessions(&self) -> Result<usize>
Clean up expired sessions
pub fn is_enabled(&self) -> bool
pub fn is_api_key_enabled(&self) -> bool
pub fn is_mtls_enabled(&self) -> bool
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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