Skip to content
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

LG-12571 Specify "hints" for WebAuthn security key enrollment #10382

Merged
merged 7 commits into from
Apr 10, 2024

Conversation

kevinsmaster5
Copy link
Contributor

🎫 Ticket

LG-12571

🛠 Summary of changes

When enrolling a non-platform webauthn device it passes the value 'security-key' with the authenticatorSelection object.
Platform devices will have 'client-device' added.
https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialhints-client-device

📜 Testing Plan

Test for enroll-webauthn-device should pass.
Setup should work as before without any issues.

@@ -56,6 +56,7 @@ function webauthn() {
.filter(Boolean),
),
authenticatorAttachment: platformAuthenticator ? 'platform' : 'cross-platform',
publicKeyCredentialHints: platformAuthenticator ? 'client-device' : 'security-key',
Copy link
Member

Choose a reason for hiding this comment

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

I think we should support "hybrid" for platform authenticator enrollments, like using a smartphone QR code to complete MFA setup initiated on a computer. I'd think we should either leave the hints unspecified for platform authenticators, or provide an array including both client-device and hybrid (in order of preference).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added 'hybrid' into the acceptable options.

@@ -37,6 +39,10 @@ interface EnrollResult {
transports?: string[];
}

interface AuthenticatorSelectionCriteriaWithHints extends AuthenticatorSelectionCriteria {
publicKeyCredentialHints?: 'client-device' | 'security-key';
Copy link
Member

Choose a reason for hiding this comment

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

  1. The property of publicKey is called hints, not publicKeyCredentialHints
  2. The value is an array of strings, not a string
  3. 'hybrid' is a valid hints string value

Reference: https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-hints

Suggested change
publicKeyCredentialHints?: 'client-device' | 'security-key';
hints?: Array<'client-device' | 'security-key' | 'hybrid'>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated value to array of strings and set property name to 'hints'

@@ -23,6 +23,8 @@ interface EnrollOptions {
excludeCredentials: PublicKeyCredentialDescriptor[];

authenticatorAttachment?: AuthenticatorAttachment;

publicKeyCredentialHints?: 'client-device' | 'security-key';
Copy link
Contributor

Choose a reason for hiding this comment

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

since this 'client-device' | 'security-key' union is used in two spots, should we name it & typedef it?

typedef PublicKeyCredentialType = 'client-device' | 'security-key';

Copy link
Member

Choose a reason for hiding this comment

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

I like that idea. Could even use an enum and call it the same as in the spec, PublicKeyCredentialHints

https://www.w3.org/TR/webauthn-3/#enumdef-publickeycredentialhints
https://www.typescriptlang.org/docs/handbook/enums.html#string-enums

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have those cast in a Type now. I'm not entirely clear on how to leverage an enum there but can spend a little more time on it.

@kevinsmaster5 kevinsmaster5 marked this pull request as ready for review April 9, 2024 19:21
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@kevinsmaster5 kevinsmaster5 merged commit 41532cb into main Apr 10, 2024
2 checks passed
@kevinsmaster5 kevinsmaster5 deleted the kmas-lg-12571-specify-webauthn-hints branch April 10, 2024 17:10
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.

None yet

3 participants