pub struct UserManager { /* private fields */ }Expand description
Implementations§
Source§impl UserManager
impl UserManager
Sourcepub fn new(storage: Arc<dyn AuthStorage>) -> Self
pub fn new(storage: Arc<dyn AuthStorage>) -> Self
Sourcepub async fn create_api_key(
&self,
user_id: &str,
expires_in: Option<Duration>,
) -> Result<String>
pub async fn create_api_key( &self, user_id: &str, expires_in: Option<Duration>, ) -> Result<String>
Sourcepub async fn validate_api_key(&self, api_key: &str) -> Result<UserInfo>
pub async fn validate_api_key(&self, api_key: &str) -> Result<UserInfo>
Sourcepub async fn revoke_api_key(&self, api_key: &str) -> Result<()>
pub async fn revoke_api_key(&self, api_key: &str) -> Result<()>
Sourcepub async fn validate_username(&self, username: &str) -> Result<bool>
pub async fn validate_username(&self, username: &str) -> Result<bool>
Sourcepub async fn validate_display_name(&self, display_name: &str) -> Result<bool>
pub async fn validate_display_name(&self, display_name: &str) -> Result<bool>
Sourcepub async fn validate_password_strength(&self, password: &str) -> Result<bool>
pub async fn validate_password_strength(&self, password: &str) -> Result<bool>
Sourcepub async fn validate_user_input(&self, input: &str) -> Result<bool>
pub async fn validate_user_input(&self, input: &str) -> Result<bool>
Validate user input for security.
Combines a character whitelist with pattern checks for common injection vectors. Rejects HTML tags, null bytes, path traversal sequences, template injection markers, and dangerous URI schemes.
§Example
ⓘ
assert!(um.validate_user_input("hello world").await?);
assert!(!um.validate_user_input("<script>alert(1)</script>").await?);Sourcepub async fn get_user_info(&self, user_id: &str) -> Result<UserInfo>
pub async fn get_user_info(&self, user_id: &str) -> Result<UserInfo>
Sourcepub async fn list_users(
&self,
limit: Option<usize>,
offset: Option<usize>,
active_only: bool,
) -> Result<Vec<UserInfo>>
pub async fn list_users( &self, limit: Option<usize>, offset: Option<usize>, active_only: bool, ) -> Result<Vec<UserInfo>>
Sourcepub async fn user_exists(&self, user_id: &str) -> Result<bool>
pub async fn user_exists(&self, user_id: &str) -> Result<bool>
Sourcepub async fn register_user(
&self,
username: &str,
email: &str,
password: &str,
) -> Result<String>
pub async fn register_user( &self, username: &str, email: &str, password: &str, ) -> Result<String>
Sourcepub async fn delete_user(&self, username: &str) -> Result<()>
pub async fn delete_user(&self, username: &str) -> Result<()>
Sourcepub async fn delete_user_by_id(&self, user_id: &str) -> Result<()>
pub async fn delete_user_by_id(&self, user_id: &str) -> Result<()>
Sourcepub async fn get_username_by_id(&self, user_id: &str) -> Result<String>
pub async fn get_username_by_id(&self, user_id: &str) -> Result<String>
Sourcepub async fn username_exists(&self, username: &str) -> Result<bool>
pub async fn username_exists(&self, username: &str) -> Result<bool>
Sourcepub async fn email_exists(&self, email: &str) -> Result<bool>
pub async fn email_exists(&self, email: &str) -> Result<bool>
Sourcepub async fn get_user_profile(&self, user_id: &str) -> Result<ProviderProfile>
pub async fn get_user_profile(&self, user_id: &str) -> Result<ProviderProfile>
Sourcepub async fn verify_login_credentials(
&self,
username: &str,
password: &str,
) -> Result<Option<CredentialCheckResult>>
pub async fn verify_login_credentials( &self, username: &str, password: &str, ) -> Result<Option<CredentialCheckResult>>
Verify username/password credentials in a timing-safe manner.
Returns Ok(None) when the credentials are invalid — a dummy Argon2
verification is always executed when the username is not found, so
callers cannot distinguish missing users from wrong passwords via timing.
Returns Ok(Some(result)) on success.
§Example
ⓘ
match um.verify_login_credentials("alice", "password123").await? {
Some(cred) => println!("user_id={}, mfa={}", cred.user_id, cred.mfa_enabled),
None => println!("invalid credentials"),
}Auto Trait Implementations§
impl Freeze for UserManager
impl !RefUnwindSafe for UserManager
impl Send for UserManager
impl Sync for UserManager
impl Unpin for UserManager
impl UnsafeUnpin for UserManager
impl !UnwindSafe for UserManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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