]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tfa: handle incompatible challenge data
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 19 Nov 2021 13:10:57 +0000 (14:10 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 19 Nov 2021 13:12:31 +0000 (14:12 +0100)
by returning default data, in case the challenge data is not parseable.
this allows a new challenge to be started for the userid in question
without manual cleanup.

currently this can be triggered if an ongoing challenge created with
webauthn-rs 0.2.5 is stored in /run and attempted to be read
post-upgrade.

Reported-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/config/tfa.rs

index 0e0b7638d87e7dc0d85171afeccde884913c7aa1..cb34f26cbea4e58ea3edb8f7940093bb453d6597 100644 (file)
@@ -256,13 +256,17 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
         let inner = if data.is_empty() {
             Default::default()
         } else {
-            serde_json::from_slice(&data).map_err(|err| {
-                format_err!(
-                    "failed to parse challenge data for user {}: {}",
-                    userid,
-                    err
-                )
-            })?
+            match serde_json::from_slice(&data) {
+                Ok(inner) => inner,
+                Err(err) => {
+                    eprintln!(
+                        "failed to parse challenge data for user {}: {}",
+                        userid,
+                        err
+                    );
+                    Default::default()
+                },
+            }
         };
 
         Ok(TfaUserChallengeData {