diff --git a/src/auth/two_factor.rs b/src/auth/two_factor.rs index 2d02417a..9eedf98b 100644 --- a/src/auth/two_factor.rs +++ b/src/auth/two_factor.rs @@ -12,7 +12,7 @@ use crate::{ static JWT_2FA_AUTH_ISSUER: LazyLock = LazyLock::new(|| format!("{}|api.2fa", CONFIG.domain_origin())); #[derive(Serialize, Deserialize)] -pub struct TwopFactorClaims { +pub struct TwoFactorClaims { // Not before pub nbf: i64, // Expiration time @@ -29,21 +29,25 @@ pub struct TwopFactorClaims { #[derive(Serialize, Deserialize)] pub struct AuthenticatorClaims { + #[serde(rename = "authenticator_key")] pub key: String, } #[derive(Serialize, Deserialize)] pub struct DuoClaims { - data: Option, + #[serde(rename = "duo_data")] + pub data: Option, } #[derive(Serialize, Deserialize)] pub struct WebauthnClaims { + #[serde(rename = "webauthn_keys")] pub keys: Vec, } #[derive(Serialize, Deserialize)] pub struct YubikeyClaims { + #[serde(rename = "yubi_keys")] pub keys: Vec, } @@ -102,7 +106,7 @@ pub struct EmailClaims { fn token(user_id: UserId, enabled: bool, claims: T) -> String { let time_now = Utc::now(); - let claims = TwopFactorClaims { + let claims = TwoFactorClaims { nbf: time_now.timestamp(), exp: (time_now + TimeDelta::try_minutes(5).unwrap()).timestamp(), iss: JWT_2FA_AUTH_ISSUER.to_string(), @@ -114,7 +118,7 @@ fn token(user_id: UserId, enabled: bool, claims: T) -> String { } fn validate(token: &str, user_id: &UserId, enabled: bool) -> ApiResult { - match decode_jwt::>(token, JWT_2FA_AUTH_ISSUER.to_string()) { + match decode_jwt::>(token, JWT_2FA_AUTH_ISSUER.to_string()) { Ok(claims) => { if claims.sub != *user_id { err!("Invalid verification token: Invalid user");