pub struct MfaManager { /* private fields */ }Expand description
MFA 管理器:管理用户的 MFA 密钥和验证状态
Implementations§
Source§impl MfaManager
impl MfaManager
pub fn new() -> Self
Sourcepub fn generate_secret(
&self,
user_id: &str,
account: impl Into<String>,
issuer: impl Into<String>,
) -> MfaSecret
pub fn generate_secret( &self, user_id: &str, account: impl Into<String>, issuer: impl Into<String>, ) -> MfaSecret
为用户生成新的 MFA 密钥
Sourcepub fn bind_secret(&self, user_id: &str, secret: MfaSecret)
pub fn bind_secret(&self, user_id: &str, secret: MfaSecret)
为用户绑定已有密钥
Sourcepub fn generate_code(&self, user_id: &str) -> Result<String, AuthError>
pub fn generate_code(&self, user_id: &str) -> Result<String, AuthError>
生成用户当前的 TOTP 码(用于测试或重置流程)
Sourcepub fn remove_secret(&self, user_id: &str) -> bool
pub fn remove_secret(&self, user_id: &str) -> bool
移除用户的 MFA 密钥
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MfaManager
impl !RefUnwindSafe for MfaManager
impl Send for MfaManager
impl Sync for MfaManager
impl Unpin for MfaManager
impl UnsafeUnpin for MfaManager
impl UnwindSafe for MfaManager
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