bitwarden_core/auth/login/response/two_factor/
two_factor_providers.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::auth::login::response::two_factor::{
5    authenticator::Authenticator, duo::Duo, email::Email, remember::Remember, web_authn::WebAuthn,
6    yubi_key::YubiKey,
7};
8
9#[allow(missing_docs)]
10#[derive(Serialize, Deserialize, Debug, JsonSchema)]
11#[serde(rename_all = "camelCase", deny_unknown_fields)]
12pub struct TwoFactorProviders {
13    pub authenticator: Option<Authenticator>,
14    /// Email 2fa
15    pub email: Option<Email>,
16    /// Duo-backed 2fa
17    pub duo: Option<Duo>,
18    /// Duo-backed 2fa operated by an organization the user is a member of
19    pub organization_duo: Option<Duo>,
20    /// Yubikey-backed 2fa
21    pub yubi_key: Option<YubiKey>,
22    /// Presence indicates the user has stored this device as bypassing 2fa
23    pub remember: Option<Remember>,
24    /// WebAuthn-backed 2fa
25    pub web_authn: Option<WebAuthn>,
26}
27
28impl From<crate::auth::api::response::TwoFactorProviders> for TwoFactorProviders {
29    fn from(api: crate::auth::api::response::TwoFactorProviders) -> Self {
30        Self {
31            authenticator: api.authenticator.map(|_| Authenticator {}),
32            email: api.email.map(Into::into),
33            duo: api.duo.map(Into::into),
34            organization_duo: api.organization_duo.map(Into::into),
35            yubi_key: api.yubi_key.map(Into::into),
36            remember: api.remember.map(Into::into),
37            web_authn: api.web_authn.map(Into::into),
38        }
39    }
40}