Skip to content

Commit

Permalink
fix: discoverable should not be hard coded
Browse files Browse the repository at this point in the history
  • Loading branch information
coroiu committed Jul 16, 2024
1 parent f0dd3b9 commit d5753db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 4 additions & 3 deletions crates/bitwarden-fido/src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -455,14 +455,15 @@ 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,

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L458 was not covered by tests
) -> Result<(), InnerError> {
let enc = this
.authenticator
.client
.internal
.get_encryption_settings()?;

let cred = try_from_credential_full(cred, user, rp)?;
let cred = try_from_credential_full(cred, user, rp, options)?;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L466 was not covered by tests

// Get the previously selected cipher and add the new credential to it
let mut selected: CipherView = this
Expand Down Expand Up @@ -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| {

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L498 was not covered by tests
error!("Error saving credential: {e:?}");
VendorError::try_from(0xF1)
.expect("Valid vendor error code")
Expand Down
4 changes: 2 additions & 2 deletions crates/bitwarden-fido/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}
Expand All @@ -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,

Check warning on line 189 in crates/bitwarden-fido/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-fido/src/lib.rs#L189

Added line #L189 was not covered by tests
) -> Result<Fido2CredentialFullView, FillCredentialError> {
let cred_id: Vec<u8> = value.credential_id.into();
let key_value = URL_SAFE_NO_PAD.encode(cose_key_to_pkcs8(&value.key)?);
Expand All @@ -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(),

Check warning on line 208 in crates/bitwarden-fido/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-fido/src/lib.rs#L208

Added line #L208 was not covered by tests
creation_date: chrono::offset::Utc::now(),
})
}
Expand Down
2 changes: 0 additions & 2 deletions crates/bitwarden-vault/src/cipher/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ pub struct Fido2CredentialNewView {
pub counter: String,
pub rp_name: Option<String>,
pub user_display_name: Option<String>,
pub discoverable: String,
pub creation_date: DateTime<Utc>,
}

Expand All @@ -164,7 +163,6 @@ impl From<Fido2CredentialFullView> 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,
}
}
Expand Down

0 comments on commit d5753db

Please sign in to comment.