From 902a0e8cb5b398bc2df40d7ec5e8c325a8dda4bc Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 23 Jun 2023 14:30:36 +0200 Subject: [PATCH] api: include tfa lock status in user list Like in PVE. This means that /access/users is now a 'protected' call to get access to 'tfa.cfg'. Signed-off-by: Wolfgang Bumiller --- pbs-api-types/src/user.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pbs-api-types/src/user.rs b/pbs-api-types/src/user.rs index 21bf0e61..595c8702 100644 --- a/pbs-api-types/src/user.rs +++ b/pbs-api-types/src/user.rs @@ -73,9 +73,20 @@ pub const EMAIL_SCHEMA: Schema = StringSchema::new("E-Mail Address.") type: ApiToken }, }, + "totp-locked": { + type: bool, + optional: true, + default: false, + description: "True if the user is currently locked out of TOTP factors", + }, + "tfa-locked-until": { + optional: true, + description: "Contains a timestamp until when a user is locked out of 2nd factors", + }, } )] #[derive(Serialize, Deserialize, Clone, PartialEq)] +#[serde(rename_all = "kebab-case")] /// User properties with added list of ApiTokens pub struct UserWithTokens { pub userid: Userid, @@ -93,6 +104,14 @@ pub struct UserWithTokens { pub email: Option, #[serde(skip_serializing_if = "Vec::is_empty", default)] pub tokens: Vec, + #[serde(skip_serializing_if = "bool_is_false")] + pub totp_locked: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub tfa_locked_until: Option, +} + +fn bool_is_false(b: &bool) -> bool { + !b } #[api(