-
Notifications
You must be signed in to change notification settings - Fork 19
Implement Credential Management #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Credential Management #67
Conversation
AlfioEmanueleFresta
left a comment
There was a problem hiding this 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( |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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:
- Currently use Ctap2 models directly within high-level traits, eg.
pub struct MakeCredentialRequest { pub hash: Vec<u8>, pub origin: String, pub relying_party: Ctap2PublicKeyCredentialRpEntity,
- Typealias other types as a shortcut:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense
AlfioEmanueleFresta
left a comment
There was a problem hiding this 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.
Fixes #24