Skip to content

Conversation

@msirringhaus
Copy link
Collaborator

@msirringhaus msirringhaus commented Oct 9, 2025

First shot at supporting NFC.

  • Switched to my libwebauthn fork for now, until it lands (so this PR can be considered a draft)
  • nfc.rs is more or less a direct copy of usb.rs with the removal of "selecting device" which as of now isn't a thing in the NFC-implementation of libwebauthn. They probably could also share most/all of the code, but I'm not sure yet if we would want that.
  • I also had the GUI-side duplicated, but de-duplicated it later on. Not sure which way we want to go there. Both are there in the history, so easily just one or the other
  • Changed the icon to the not-really-fitting wifi-symbol, as I couldn't find any nfc-icons in the common themes.
  • get_available_public_key_devices() is not using a static list anymore but dynamically checks on each call if NFC is available (because someone may plug in their NFC reader and try again).
  • No additional tests for now

@msirringhaus msirringhaus requested a review from iinuwa October 9, 2025 11:57
Copy link
Member

@AlfioEmanueleFresta AlfioEmanueleFresta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@iinuwa iinuwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! A couple of doc comments need to be updated, and then I'm fine with merging this. Thanks for bringing this to the finish line!

/// Awaiting FIDO USB device to be plugged in.
Waiting,

/// USB device connected, prompt user to tap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// USB device connected, prompt user to tap
/// NFC device connected, prompt user to tap

#[default]
Idle,

/// Awaiting FIDO USB device to be plugged in.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Awaiting FIDO USB device to be plugged in.
/// Awaiting FIDO NFC device to connect.

/// Used to share public state between credential service and UI.
#[derive(Clone, Debug, Default)]
pub enum NfcState {
/// Not polling for FIDO USB device.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Not polling for FIDO USB device.
/// Not polling for FIDO NFC device.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine to reuse for now, but I think soon we'll need to distinguish between different types of NFC devices to display the right kind of icon to the user. Cf. w3c/webauthn#2360.

Comment on lines +48 to +56
} else {
tracing::warn!(
"Failed to list NFC authenticators: {:?}. Throttling NFC state updates",
err
);
tokio::time::sleep(Duration::from_secs(1)).await;
Ok(prev_nfc_state.clone())
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these failures happen often on NFC? Maybe we can add a comment saying that we should try to push this error handling into libwebauthn?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I have ever seen one in my testing. This was also copied over from usb and left as a "just in case"-error handling.

@iinuwa
Copy link
Member

iinuwa commented Nov 14, 2025

nfc.rs is more or less a direct copy of usb.rs with the removal of "selecting device" which as of now isn't a thing in the NFC-implementation of libwebauthn. They probably could also share most/all of the code, but I'm not sure yet if we would want that.

Yeah, we've only got 2 transports left. I think once those are done, I'll want to go back and at least extract out the common methods between all the different transports, because they all have basically the same shape, especially near the end of the ceremonies.

I also had the GUI-side duplicated, but de-duplicated it later on. Not sure which way we want to go there. Both are there in the history, so easily just one or the other

let's keep it merged for now.

Changed the icon to the not-really-fitting wifi-symbol, as I couldn't find any nfc-icons in the common themes.

Yeah, the NFC one is trademarked, so you have to sign a licensing agreement to be able to use it. Not sure if we're even able to sign it since this project is not a legal entity worth it, but I'll add an issue to check it out.

get_available_public_key_devices() is not using a static list anymore but dynamically checks on each call if NFC is available (because someone may plug in their NFC reader and try again).

Thank you!

@iinuwa iinuwa merged commit 3817f7f into linux-credentials:main Nov 28, 2025
1 check passed
@iinuwa
Copy link
Member

iinuwa commented Nov 28, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants