From 8ab1d131406fc7604beb2f87be09f7d2c86d99a3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 25 Jul 2022 13:39:41 +0200 Subject: [PATCH] tfa: allow modifying 'allow-subdomains' Signed-off-by: Wolfgang Bumiller --- src/api2/config/access/tfa.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/api2/config/access/tfa.rs b/src/api2/config/access/tfa.rs index 814fc0f3..8b2ca46a 100644 --- a/src/api2/config/access/tfa.rs +++ b/src/api2/config/access/tfa.rs @@ -53,8 +53,11 @@ pub fn get_webauthn_config( #[serde(rename_all = "kebab-case")] /// Deletable property name pub enum DeletableProperty { - /// Delete the origin property. + /// Delete the `origin` property. Origin, + + /// Delete the `allow_subdomains` property. + AllowSubdomains, } #[api( @@ -105,6 +108,9 @@ pub fn update_webauthn_config( DeletableProperty::Origin => { wa.origin = None; } + DeletableProperty::AllowSubdomains => { + wa.allow_subdomains = None; + } } } } @@ -115,6 +121,9 @@ pub fn update_webauthn_config( if webauthn.origin.is_some() { wa.origin = webauthn.origin; } + if webauthn.allow_subdomains.is_some() { + wa.allow_subdomains = webauthn.allow_subdomains; + } if let Some(id) = webauthn.id { wa.id = id; } @@ -126,7 +135,13 @@ pub fn update_webauthn_config( let id = webauthn .id .ok_or_else(|| format_err!("missing property: 'id'"))?; - tfa.webauthn = Some(WebauthnConfig { rp, origin, id }); + let allow_subdomains = webauthn.allow_subdomains; + tfa.webauthn = Some(WebauthnConfig { + rp, + origin, + id, + allow_subdomains, + }); } tfa::write(&tfa)?;