From d5753dba9ea13461f049645de76d3e8e2d2e3b3e Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Tue, 16 Jul 2024 10:32:18 +0200 Subject: [PATCH] fix: `discoverable` should not be hard coded --- crates/bitwarden-fido/src/authenticator.rs | 7 ++++--- crates/bitwarden-fido/src/lib.rs | 4 ++-- crates/bitwarden-vault/src/cipher/login.rs | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index 9d4371476..cbddaf94b 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -430,7 +430,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { cred: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, - _options: passkey::types::ctap2::get_assertion::Options, + options: passkey::types::ctap2::get_assertion::Options, ) -> Result<(), StatusCode> { #[derive(Debug, Error)] enum InnerError { @@ -455,6 +455,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { cred: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, + options: passkey::types::ctap2::get_assertion::Options, ) -> Result<(), InnerError> { let enc = this .authenticator @@ -462,7 +463,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .internal .get_encryption_settings()?; - let cred = try_from_credential_full(cred, user, rp)?; + let cred = try_from_credential_full(cred, user, rp, options)?; // Get the previously selected cipher and add the new credential to it let mut selected: CipherView = this @@ -494,7 +495,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { Ok(()) } - inner(self, cred, user, rp).await.map_err(|e| { + inner(self, cred, user, rp, options).await.map_err(|e| { error!("Error saving credential: {e:?}"); VendorError::try_from(0xF1) .expect("Valid vendor error code") diff --git a/crates/bitwarden-fido/src/lib.rs b/crates/bitwarden-fido/src/lib.rs index a4bbf5662..991828eb3 100644 --- a/crates/bitwarden-fido/src/lib.rs +++ b/crates/bitwarden-fido/src/lib.rs @@ -178,7 +178,6 @@ pub(crate) fn try_from_credential_new_view( counter: 0.to_string(), user_name: user.name.clone(), user_display_name: user.display_name.clone(), - discoverable: "true".to_owned(), creation_date: chrono::offset::Utc::now(), }) } @@ -187,6 +186,7 @@ pub(crate) fn try_from_credential_full( value: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, + options: passkey::types::ctap2::get_assertion::Options, ) -> Result { let cred_id: Vec = value.credential_id.into(); let key_value = URL_SAFE_NO_PAD.encode(cose_key_to_pkcs8(&value.key)?); @@ -205,7 +205,7 @@ pub(crate) fn try_from_credential_full( counter: value.counter.unwrap_or(0).to_string(), user_name: user.name, user_display_name: user.display_name, - discoverable: "true".to_owned(), + discoverable: options.rk.to_string(), creation_date: chrono::offset::Utc::now(), }) } diff --git a/crates/bitwarden-vault/src/cipher/login.rs b/crates/bitwarden-vault/src/cipher/login.rs index d524a724a..4b476b075 100644 --- a/crates/bitwarden-vault/src/cipher/login.rs +++ b/crates/bitwarden-vault/src/cipher/login.rs @@ -147,7 +147,6 @@ pub struct Fido2CredentialNewView { pub counter: String, pub rp_name: Option, pub user_display_name: Option, - pub discoverable: String, pub creation_date: DateTime, } @@ -164,7 +163,6 @@ impl From for Fido2CredentialNewView { counter: value.counter, rp_name: value.rp_name, user_display_name: value.user_display_name, - discoverable: value.discoverable, creation_date: value.creation_date, } }