Skip to content
Open
Show file tree
Hide file tree
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
687 changes: 542 additions & 145 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion credentialsd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async-trait = "0.1.89"
base64 = "0.22.1"
credentialsd-common = { path = "../credentialsd-common" }
futures-lite.workspace = true
libwebauthn = { git = "https://github.com/linux-credentials/libwebauthn.git", rev="80545bff16c4e89a930221e90d3141a76303b84b", features = ["libnfc","pcsc"] }
libwebauthn = { version = "0.3.0", features = ["libnfc","pcsc"] }
# TODO: split nfc and pcsc into separate features
# Also, 0.6.1 fails to build with non-vendored library.
# https://github.com/alexrsagen/rs-nfc1/issues/15
Expand Down
8 changes: 7 additions & 1 deletion credentialsd/src/credential_service/hybrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ impl HybridHandler for InternalHybridHandler {
QrCodeOperationHint::GetAssertionRequest
}
};
let mut device = CableQrCodeDevice::new_transient(hint);
let mut device = match CableQrCodeDevice::new_transient(hint) {
Ok(device) => device,
Err(err) => {
tracing::error!("Failed to create caBLE QR code device: {:?}", err);
return;
}
};
let qr_code = device.qr_code.to_string();
if let Err(err) = tx.send(HybridStateInternal::Init(qr_code)).await {
tracing::error!("Failed to send caBLE update: {:?}", err);
Expand Down
17 changes: 9 additions & 8 deletions credentialsd/src/credential_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ impl From<GetAssertionResponse> for AuthenticatorResponse {
mod test {
use std::{sync::Arc, time::Duration};

use base64::Engine as _;
use libwebauthn::{
ops::webauthn::{
MakeCredentialRequest, ResidentKeyRequirement, UserVerificationRequirement,
Expand All @@ -396,9 +397,7 @@ mod test {
credential_service::usb::InProcessUsbHandler,
dbus::test::{DummyFlowServer, DummyUiServer},
model::CredentialRequest,
webauthn::{self, NavigationContext},
};
use credentialsd_common::model::Operation;

use super::{
hybrid::{test::DummyHybridHandler, HybridStateInternal},
Expand Down Expand Up @@ -456,13 +455,15 @@ mod test {

fn create_credential_request() -> CredentialRequest {
let challenge = "Ox0AXQz7WUER7BGQFzvVrQbReTkS3sepVGj26qfUhhrWSarkDbGF4T4NuCY1aAwHYzOzKMJJ2YRSatetl0D9bQ";
let origin = NavigationContext::SameOrigin("https://webauthn.io".parse().unwrap());
let client_data_json =
webauthn::format_client_data_json(Operation::Create, challenge, &origin);
let client_data_hash = webauthn::create_client_data_hash(&client_data_json);
let origin = "webauthn.io".to_string();
let is_cross_origin = false;
let challenge_bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD
.decode(challenge)
.expect("valid base64url challenge");
let make_request = MakeCredentialRequest {
hash: client_data_hash,
origin: "https://webauthn.io".to_string(),
challenge: challenge_bytes,
origin: origin.clone(),
cross_origin: Some(is_cross_origin),
relying_party: Ctap2PublicKeyCredentialRpEntity {
id: "webauthn.io".to_string(),
name: Some("webauthn.io".to_string()),
Expand Down
10 changes: 8 additions & 2 deletions credentialsd/src/credential_service/nfc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ impl InProcessNfcHandler {
prev_nfc_state: &NfcStateInternal,
) -> Result<NfcStateInternal, Error> {
match libwebauthn::transport::nfc::get_nfc_device().await {
Ok(None) => Ok(NfcStateInternal::Waiting),
Ok(Some(hid_device)) => Ok(NfcStateInternal::Connected(hid_device)),
Ok(Some(nfc_device)) => Ok(NfcStateInternal::Connected(nfc_device)),
Ok(None) => {
let state = NfcStateInternal::Waiting;
Comment thread
msirringhaus marked this conversation as resolved.
Ok(state)
}
Err(err) => {
*failures += 1;
if *failures == 5 {
Expand Down Expand Up @@ -527,6 +530,9 @@ async fn handle_nfc_updates(
UvUpdate::PresenceRequired => {
tracing::debug!("Authenticator requested user presence, but that makes no sense for NFC. Skipping");
}
UvUpdate::PinNotSet(_) => {
tracing::error!("Authenticator requested PIN setup, which is not yet supported.");
}
}
}
debug!("NFC update channel closed.");
Expand Down
3 changes: 3 additions & 0 deletions credentialsd/src/credential_service/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ async fn handle_usb_updates(
tracing::error!("Authenticator requested user presence, but we cannot relay the message to the credential service: {:?}", err);
}
}
UvUpdate::PinNotSet(_) => {
tracing::error!("Authenticator requested PIN setup, which is not yet supported.");
}
}
}
debug!("USB update channel closed.");
Expand Down
Loading
Loading