pub struct MfaOperations<'a> { /* private fields */ }Expand description
Focused multi-factor authentication operations exposed via AuthFramework::mfa().
Covers TOTP, SMS, email challenges, backup codes, and MFA completion flows.
§Example
let mfa = auth.mfa();
// Set up TOTP for a user
let secret = mfa.generate_totp_secret("user_123").await?;
let qr_url = mfa.generate_totp_qr_url("user_123", "MyApp", &secret).await?;
// Verify a code supplied by the user
let valid = mfa.verify_totp("user_123", "123456").await?;Implementations§
Source§impl MfaOperations<'_>
impl MfaOperations<'_>
Sourcepub async fn complete(
&self,
challenge: MfaChallenge,
code: &str,
) -> Result<AuthToken>
pub async fn complete( &self, challenge: MfaChallenge, code: &str, ) -> Result<AuthToken>
Complete a pending MFA challenge with the provided code.
Sourcepub async fn complete_by_id(
&self,
challenge_id: &str,
code: &str,
) -> Result<AuthToken>
pub async fn complete_by_id( &self, challenge_id: &str, code: &str, ) -> Result<AuthToken>
Complete a pending MFA challenge by its ID.
Sourcepub async fn initiate_sms(&self, user_id: &str) -> Result<String>
pub async fn initiate_sms(&self, user_id: &str) -> Result<String>
Initiate an SMS-based MFA challenge for a user.
Sourcepub async fn verify_sms(&self, challenge_id: &str, code: &str) -> Result<bool>
pub async fn verify_sms(&self, challenge_id: &str, code: &str) -> Result<bool>
Verify an SMS challenge code.
Sourcepub async fn initiate_email(&self, user_id: &str) -> Result<String>
pub async fn initiate_email(&self, user_id: &str) -> Result<String>
Initiate an email-based MFA challenge for a user.
Sourcepub async fn register_phone(
&self,
user_id: &str,
phone_number: &str,
) -> Result<()>
pub async fn register_phone( &self, user_id: &str, phone_number: &str, ) -> Result<()>
Register a phone number for SMS MFA.
Sourcepub async fn register_email(&self, user_id: &str, email: &str) -> Result<()>
pub async fn register_email(&self, user_id: &str, email: &str) -> Result<()>
Register an email address for email MFA.
Sourcepub async fn generate_totp_secret(&self, user_id: &str) -> Result<String>
pub async fn generate_totp_secret(&self, user_id: &str) -> Result<String>
Generate a TOTP secret for a user.
Sourcepub async fn generate_totp_qr_url(
&self,
user_id: &str,
app_name: &str,
secret: &str,
) -> Result<String>
pub async fn generate_totp_qr_url( &self, user_id: &str, app_name: &str, secret: &str, ) -> Result<String>
Generate a TOTP QR code provisioning URL.
Sourcepub async fn generate_totp_code(&self, secret: &str) -> Result<String>
pub async fn generate_totp_code(&self, secret: &str) -> Result<String>
Generate the current TOTP code for a secret.
Auto Trait Implementations§
impl<'a> Freeze for MfaOperations<'a>
impl<'a> !RefUnwindSafe for MfaOperations<'a>
impl<'a> Send for MfaOperations<'a>
impl<'a> Sync for MfaOperations<'a>
impl<'a> Unpin for MfaOperations<'a>
impl<'a> UnsafeUnpin for MfaOperations<'a>
impl<'a> !UnwindSafe for MfaOperations<'a>
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