1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-09-22 01:22:41 +00:00

Fix an issue with yubico keys not validating

When adding or updating yubico otp keys there were some issues with the validation.
Looks like the web-vault sends all keys, not only filled-in keys, which triggered a check on empty keys.
Also, we should only return filled-in keys, not the empty ones too.

Fixes #5986

Signed-off-by: BlackDex <black.dex@gmail.com>
This commit is contained in:
BlackDex 2025-06-26 16:51:08 +02:00
commit 33d7486516
No known key found for this signature in database
GPG key ID: 58C80A2AA6C765E1

View file

@ -145,15 +145,23 @@ async fn activate_yubikey(data: Json<EnableYubikeyData>, headers: Headers, mut c
// Ensure they are valid OTPs
for yubikey in &yubikeys {
if yubikey.len() == 12 {
// YubiKey ID
if yubikey.is_empty() || yubikey.len() == 12 {
continue;
}
verify_yubikey_otp(yubikey.to_owned()).await.map_res("Invalid Yubikey OTP provided")?;
}
let yubikey_ids: Vec<String> = yubikeys.into_iter().map(|x| (x[..12]).to_owned()).collect();
let yubikey_ids: Vec<String> = yubikeys
.into_iter()
.filter_map(|x| {
if x.len() >= 12 {
Some((x[..12]).to_owned())
} else {
None
}
})
.collect();
let yubikey_metadata = YubikeyMetadata {
keys: yubikey_ids,