Disable Yubikey 2FA if 0 Keys Provided

This commit is contained in:
Stepan Fedorko-Bartos 2018-11-16 12:07:00 -07:00
parent 82e2b8a8c0
commit aba9c28226
1 changed files with 7 additions and 0 deletions

View File

@ -630,6 +630,13 @@ fn activate_yubikey(data: JsonUpcase<EnableYubikeyData>, 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 {