pub struct AuthManager { /* private fields */ }Expand description
Authentication manager
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn register_user(
&self,
username: String,
email: String,
password: &str,
role: Role,
tenant_id: String,
) -> Result<User>
pub fn register_user( &self, username: String, email: String, password: &str, role: Role, tenant_id: String, ) -> Result<User>
Register a new user
Sourcepub fn authenticate(&self, username: &str, password: &str) -> Result<String>
pub fn authenticate(&self, username: &str, password: &str) -> Result<String>
Authenticate user with username and password
Sourcepub fn validate_token(&self, token: &str) -> Result<Claims>
pub fn validate_token(&self, token: &str) -> Result<Claims>
Validate JWT token
Sourcepub fn create_api_key(
&self,
name: String,
tenant_id: String,
role: Role,
expires_at: Option<DateTime<Utc>>,
) -> (ApiKey, String)
pub fn create_api_key( &self, name: String, tenant_id: String, role: Role, expires_at: Option<DateTime<Utc>>, ) -> (ApiKey, String)
Create API key
Sourcepub fn validate_api_key(&self, key: &str) -> Result<Claims>
pub fn validate_api_key(&self, key: &str) -> Result<Claims>
Validate API key
Sourcepub fn list_users(&self) -> Vec<User>
pub fn list_users(&self) -> Vec<User>
List all users (admin only)
Sourcepub fn delete_user(&self, user_id: &Uuid) -> Result<()>
pub fn delete_user(&self, user_id: &Uuid) -> Result<()>
Delete user
Sourcepub fn revoke_api_key(&self, key_id: &Uuid) -> Result<()>
pub fn revoke_api_key(&self, key_id: &Uuid) -> Result<()>
Revoke API key
Sourcepub fn list_api_keys(&self, tenant_id: &str) -> Vec<ApiKey>
pub fn list_api_keys(&self, tenant_id: &str) -> Vec<ApiKey>
List API keys for a tenant
Trait Implementations§
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