pub struct TwoFactorPlugin { /* private fields */ }Expand description
Two-factor authentication plugin providing TOTP, OTP, and backup code flows.
Implementations§
Source§impl TwoFactorPlugin
impl TwoFactorPlugin
pub fn new() -> Self
pub fn with_config(config: TwoFactorConfig) -> Self
pub fn issuer(self, val: impl Into<String>) -> Self
pub fn backup_code_count(self, val: usize) -> Self
pub fn backup_code_length(self, val: usize) -> Self
pub fn totp_period(self, val: u64) -> Self
pub fn totp_digits(self, val: usize) -> Self
Trait Implementations§
Source§impl<DB: DatabaseAdapter> AuthPlugin<DB> for TwoFactorPlugin
impl<DB: DatabaseAdapter> AuthPlugin<DB> for TwoFactorPlugin
Source§fn on_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called for each request - return Some(response) to handle, None to pass through
Source§fn on_init<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn on_init<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Called when the plugin is initialized
Source§fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
_ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<Option<BeforeRequestAction>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
_ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<Option<BeforeRequestAction>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called before route matching for every incoming request. Read more
Source§fn on_user_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 <DB as UserOps>::User,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_user_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 <DB as UserOps>::User,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called after a user is created
Source§fn on_session_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session: &'life1 <DB as SessionOps>::Session,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_session_created<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session: &'life1 <DB as SessionOps>::Session,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called after a session is created
Source§fn on_user_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_user_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called before a user is deleted
Source§fn on_session_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_token: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_session_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_token: &'life1 str,
ctx: &'life2 AuthContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Called before a session is deleted
Auto Trait Implementations§
impl Freeze for TwoFactorPlugin
impl RefUnwindSafe for TwoFactorPlugin
impl Send for TwoFactorPlugin
impl Sync for TwoFactorPlugin
impl Unpin for TwoFactorPlugin
impl UnsafeUnpin for TwoFactorPlugin
impl UnwindSafe for TwoFactorPlugin
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