Skip to content

Conversation

@msirringhaus
Copy link
Collaborator

@msirringhaus msirringhaus commented Feb 11, 2025

Fixes #24

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.

Thank you so much for your work on this @msirringhaus!

A few notes, and as this is net new functionality without a stable API, I'll leave the decision as to how much to address here or a separate PR to your judgement.

pin_provider: &mut Box<dyn PinProvider>,
timeout: Duration,
) -> Result<Ctap2CredentialManagementMetadata, Error>;
async fn enumerate_rps_begin(

Choose a reason for hiding this comment

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

Would it make sense for the higher level APIs (enumerate_rps, enumerate_credentials) to return Iterators?

(No need to address this in this PR.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure how nice that would be to use, since each iteration could fail and may needs to be retried.
Maybe simpler would be to move all the logic of the example inside libwebauthn, and only have a single enumerate_credentials()-function that already collects all RPs and all credentials and returns a map with all the content?
Depends a bit on how low-level we want the API to be. We have the same "problem" with e.g. BioEnrollments.

)
}?;
let metadata = Ctap2CredentialManagementMetadata::new(
resp.existing_resident_credentials_count.unwrap(),

Choose a reason for hiding this comment

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

I'm not very comfortable with unwraps on authenticator response fields. IMO we should treat the response as untrusted - WDYT?

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 would agree. We have this however in lots of other places. I'll create a follow up issue to fix this all in one PR, ok?

&mut self,
pin_provider: &mut Box<dyn PinProvider>,
timeout: Duration,
) -> Result<(Ctap2PublicKeyCredentialRpEntity, ByteBuf, u64), Error>;

Choose a reason for hiding this comment

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

These output types may not be obvious, I think it's worth creating a struct with named fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

async fn enumerate_rps<T: CredentialManagement>(
channel: &mut T,
pin_provider: &mut Box<dyn PinProvider>,
) -> Result<Vec<(Ctap2PublicKeyCredentialRpEntity, ByteBuf)>, WebAuthnError> {

Choose a reason for hiding this comment

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

Could we expose Vec instead of ByteBuf? Thankfully this should be cheap with into_vec (source).

Context - I'd like for higher level APIs, including the WebAuthn trait, to eventually hide much of the CTAP ugliness: optional fields, protocol internals, serde types.

This isn't already the case and we have the following tech debt:

  1. Currently use Ctap2 models directly within high-level traits, eg.
    pub struct MakeCredentialRequest {
           pub hash: Vec<u8>,
           pub origin: String,
           pub relying_party: Ctap2PublicKeyCredentialRpEntity,
  2. Typealias other types as a shortcut:
    
    

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense

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.

Thanks for addressing the feedback.

@msirringhaus msirringhaus merged commit 5f0e51e into linux-credentials:master Feb 12, 2025
3 checks passed
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.

FIDO 2.1: Credential management

2 participants