From aba9c28226d4f716d4f6fbc28baf98b84262ae00 Mon Sep 17 00:00:00 2001 From: Stepan Fedorko-Bartos Date: Fri, 16 Nov 2018 12:07:00 -0700 Subject: [PATCH] Disable Yubikey 2FA if 0 Keys Provided --- src/api/core/two_factor.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api/core/two_factor.rs b/src/api/core/two_factor.rs index 3571f1e2..d4be29be 100644 --- a/src/api/core/two_factor.rs +++ b/src/api/core/two_factor.rs @@ -630,6 +630,13 @@ fn activate_yubikey(data: JsonUpcase, headers: Headers, conn: let yubikeys = parse_yubikeys(&data); + if yubikeys.len() == 0 { + return Ok(Json(json!({ + "Enabled": false, + "Object": "twoFactorU2f", + }))); + } + // Ensure they are valid OTPs for yubikey in &yubikeys { if yubikey.len() == 12 {