Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take MP reprompt into account when asserting credential #863

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions crates/bitwarden-fido/src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use bitwarden_core::{Client, VaultLocked};
use bitwarden_crypto::{CryptoError, KeyContainer, KeyEncryptable};
use bitwarden_vault::{CipherError, CipherView};
use bitwarden_vault::{CipherError, CipherRepromptType, CipherView};
use itertools::Itertools;
use log::error;
use passkey::{
Expand All @@ -20,7 +20,7 @@
};
use crate::{
fill_with_credential, string_to_guid_bytes, try_from_credential_full, Fido2CallbackError,
FillCredentialError, InvalidGuid,
FillCredentialError, InvalidGuid, Verification,

Check failure

Code scanning / clippy

unused import: Verification Error

unused import: Verification
};

#[derive(Debug, Error)]
Expand Down Expand Up @@ -631,6 +631,22 @@
user_verified: verification != UV::Discouraged,
})
}
UIHint::RequestExistingCredential(cipher)
if matches!(cipher.cipher.reprompt, CipherRepromptType::Password) =>
{
let result = self
.authenticator
.user_interface
.check_user(options, map_ui_hint(hint))
.await
.map_err(|_| Ctap2Error::OperationDenied)?;

if !result.user_verified {
return Err(Ctap2Error::UserVerificationInvalid);
}

Ok(result)
}

Check warning on line 649 in crates/bitwarden-fido/src/authenticator.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-fido/src/authenticator.rs#L634-L649

Added lines #L634 - L649 were not covered by tests
_ => {
self.authenticator
.user_interface
Expand All @@ -639,7 +655,7 @@
}
};

let result = result.map_err(|e| {
let result = result.map_err(|e: Fido2CallbackError| {

Check warning on line 658 in crates/bitwarden-fido/src/authenticator.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-fido/src/authenticator.rs#L658

Added line #L658 was not covered by tests
error!("Error checking user: {e:?}");
Ctap2Error::UserVerificationInvalid
})?;
Expand Down
Loading