pub struct BackupCodesManager { /* private fields */ }Expand description
Backup codes manager for handling backup codes
Implementations§
Source§impl BackupCodesManager
impl BackupCodesManager
Sourcepub fn new(storage: Arc<dyn AuthStorage>) -> Self
pub fn new(storage: Arc<dyn AuthStorage>) -> Self
Create a new backup codes manager
Sourcepub async fn generate_codes(
&self,
user_id: &str,
count: usize,
) -> Result<Vec<String>>
pub async fn generate_codes( &self, user_id: &str, count: usize, ) -> Result<Vec<String>>
Generate backup codes for a user. Only the digests are stored; the plaintext codes are returned once. Replaces the user’s existing codes.
Sourcepub async fn verify_code(&self, user_id: &str, code: &str) -> Result<bool>
pub async fn verify_code(&self, user_id: &str, code: &str) -> Result<bool>
Verify backup code and mark it as used
Sourcepub async fn get_remaining_count(&self, user_id: &str) -> Result<usize>
pub async fn get_remaining_count(&self, user_id: &str) -> Result<usize>
Get remaining backup codes count
Sourcepub async fn has_backup_codes(&self, user_id: &str) -> Result<bool>
pub async fn has_backup_codes(&self, user_id: &str) -> Result<bool>
Check if user has backup codes
Sourcepub async fn regenerate_codes(
&self,
user_id: &str,
count: usize,
) -> Result<Vec<String>>
pub async fn regenerate_codes( &self, user_id: &str, count: usize, ) -> Result<Vec<String>>
Regenerate backup codes (invalidating old ones)
Sourcepub async fn verify_login_code(&self, user_id: &str, code: &str) -> Result<bool>
pub async fn verify_login_code(&self, user_id: &str, code: &str) -> Result<bool>
Verify a backup code during the login MFA flow. Same store and comparison as
verify_code.
Auto Trait Implementations§
impl !RefUnwindSafe for BackupCodesManager
impl !UnwindSafe for BackupCodesManager
impl Forget for BackupCodesManager
impl Freeze for BackupCodesManager
impl Move for BackupCodesManager
impl Send for BackupCodesManager
impl Sync for BackupCodesManager
impl Unpin for BackupCodesManager
impl UnsafeUnpin for BackupCodesManager
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