pub struct AuthManager { /* private fields */ }Expand description
Authentication manager
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn with_policy(policy: PasswordPolicy) -> Self
pub fn with_policy(policy: PasswordPolicy) -> Self
Create with a specific password policy.
Sourcepub fn set_password_policy(&self, policy: PasswordPolicy)
pub fn set_password_policy(&self, policy: PasswordPolicy)
Set the password policy.
Sourcepub fn get_password_policy(&self) -> PasswordPolicy
pub fn get_password_policy(&self) -> PasswordPolicy
Get the current password policy.
Sourcepub fn create_user(
&self,
username: &'static str,
password: &str,
) -> Result<UserId, KernelError>
pub fn create_user( &self, username: &'static str, password: &str, ) -> Result<UserId, KernelError>
Create new user account.
Validates the password against the active policy before creating the account.
Sourcepub fn authenticate(&self, username: &str, password: &str) -> AuthResult
pub fn authenticate(&self, username: &str, password: &str) -> AuthResult
Authenticate user.
Checks account lock, expiration, password, and MFA status.
Sourcepub fn authenticate_mfa(
&self,
username: &str,
password: &str,
mfa_token: u32,
) -> AuthResult
pub fn authenticate_mfa( &self, username: &str, password: &str, mfa_token: u32, ) -> AuthResult
Authenticate with MFA
Sourcepub fn change_password(
&self,
username: &str,
old_password: &str,
new_password: &str,
) -> Result<(), KernelError>
pub fn change_password( &self, username: &str, old_password: &str, new_password: &str, ) -> Result<(), KernelError>
Change a user’s password.
Validates the new password against the active policy and checks password history to prevent reuse.
Sourcepub fn set_account_expiration(
&self,
username: &str,
expires_at: Option<u64>,
) -> Result<(), KernelError>
pub fn set_account_expiration( &self, username: &str, expires_at: Option<u64>, ) -> Result<(), KernelError>
Set account expiration.
Sourcepub fn enable_mfa(&self, username: &str) -> Result<[u8; 32], KernelError>
pub fn enable_mfa(&self, username: &str) -> Result<[u8; 32], KernelError>
Enable MFA for user
Sourcepub fn unlock_account(&self, username: &str) -> Result<(), KernelError>
pub fn unlock_account(&self, username: &str) -> Result<(), KernelError>
Unlock user account
Sourcepub fn delete_user(&self, username: &str) -> Result<(), KernelError>
pub fn delete_user(&self, username: &str) -> Result<(), KernelError>
Delete user account
Sourcepub fn list_usernames(&self, buf: &mut [Option<&str>]) -> usize
pub fn list_usernames(&self, buf: &mut [Option<&str>]) -> usize
List all usernames. Returns an iterator-friendly fixed-size collection.
Since we cannot return Vec<String> without heap allocation, callers
should use with_users or iterate via the returned array.
Sourcepub fn get_user_by_id(&self, user_id: UserId) -> Option<&'static str>
pub fn get_user_by_id(&self, user_id: UserId) -> Option<&'static str>
Get user by ID