TwoFactorRepository

Trait TwoFactorRepository 

Source
pub trait TwoFactorRepository: Send + Sync {
    // Required methods
    fn create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        secret: &'life1 TwoFactorSecret,
    ) -> Pin<Box<dyn Future<Output = Result<TwoFactorSecret, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn find_by_user_id<'life0, 'async_trait>(
        &'life0 self,
        user_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<TwoFactorSecret>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        secret: &'life1 TwoFactorSecret,
    ) -> Pin<Box<dyn Future<Output = Result<TwoFactorSecret, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        user_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_needing_reverification<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TwoFactorSecret>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_with_low_backup_codes<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TwoFactorSecret>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Repository port for two-factor authentication secrets

Required Methods§

Source

fn create<'life0, 'life1, 'async_trait>( &'life0 self, secret: &'life1 TwoFactorSecret, ) -> Pin<Box<dyn Future<Output = Result<TwoFactorSecret, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a new 2FA secret for a user

Source

fn find_by_user_id<'life0, 'async_trait>( &'life0 self, user_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<TwoFactorSecret>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find 2FA secret by user ID

Source

fn update<'life0, 'life1, 'async_trait>( &'life0 self, secret: &'life1 TwoFactorSecret, ) -> Pin<Box<dyn Future<Output = Result<TwoFactorSecret, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update 2FA secret (enable, disable, mark used, etc.)

Source

fn delete<'life0, 'async_trait>( &'life0 self, user_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete 2FA secret (when user disables 2FA)

Source

fn find_needing_reverification<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TwoFactorSecret>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find all users with enabled 2FA that need reverification (not used in 90 days)

Source

fn find_with_low_backup_codes<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TwoFactorSecret>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find all users with low backup codes (< 3 remaining)

Implementors§