-
-
Notifications
You must be signed in to change notification settings - Fork 67
Require discoverable credentials and user verification in README examples #501
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -176,7 +176,11 @@ end | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| options = WebAuthn::Credential.options_for_create( | ||||||||||||||||||||||
| user: { id: user.webauthn_id, name: user.name }, | ||||||||||||||||||||||
| exclude: user.credentials.map { |c| c.webauthn_id } | ||||||||||||||||||||||
| exclude: user.credentials.map { |c| c.webauthn_id }, | ||||||||||||||||||||||
| authenticator_selection: { | ||||||||||||||||||||||
| resident_key: "required", | ||||||||||||||||||||||
| user_verification: "required" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Store the newly generated challenge somewhere so you can have it | ||||||||||||||||||||||
|
|
@@ -204,7 +208,7 @@ session[:creation_challenge] = options.challenge | |||||||||||||||||||||
| webauthn_credential = WebAuthn::Credential.from_create(params[:publicKeyCredential]) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| begin | ||||||||||||||||||||||
| webauthn_credential.verify(session[:creation_challenge]) | ||||||||||||||||||||||
| webauthn_credential.verify(session[:creation_challenge], user_verification: true) | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Store Credential ID, Credential Public Key and Sign Count for future authentications | ||||||||||||||||||||||
| user.credentials.create!( | ||||||||||||||||||||||
|
|
@@ -224,7 +228,10 @@ end | |||||||||||||||||||||
| #### Initiation phase | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```ruby | ||||||||||||||||||||||
| options = WebAuthn::Credential.options_for_get(allow: user.credentials.map { |c| c.webauthn_id }) | ||||||||||||||||||||||
| options = WebAuthn::Credential.options_for_get( | ||||||||||||||||||||||
| allow: user.credentials.map { |c| c.webauthn_id }, | ||||||||||||||||||||||
| user_verification: "required" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
Comment on lines
+231
to
+234
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Store the newly generated challenge somewhere so you can have it | ||||||||||||||||||||||
| # for the verification phase. | ||||||||||||||||||||||
|
|
@@ -260,7 +267,8 @@ begin | |||||||||||||||||||||
| webauthn_credential.verify( | ||||||||||||||||||||||
| session[:authentication_challenge], | ||||||||||||||||||||||
| public_key: stored_credential.public_key, | ||||||||||||||||||||||
| sign_count: stored_credential.sign_count | ||||||||||||||||||||||
| sign_count: stored_credential.sign_count, | ||||||||||||||||||||||
| user_verification: true | ||||||||||||||||||||||
|
Comment on lines
+270
to
+271
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Update the stored credential sign count with the value from `webauthn_credential.sign_count` | ||||||||||||||||||||||
|
|
@@ -290,7 +298,11 @@ Extensions can be requested in the initiation phase in both Credential Registrat | |||||||||||||||||||||
| creation_options = WebAuthn::Credential.options_for_create( | ||||||||||||||||||||||
| user: { id: user.webauthn_id, name: user.name }, | ||||||||||||||||||||||
| exclude: user.credentials.map { |c| c.webauthn_id }, | ||||||||||||||||||||||
| extensions: { appidExclude: domain.to_s } | ||||||||||||||||||||||
| extensions: { appidExclude: domain.to_s }, | ||||||||||||||||||||||
| authenticator_selection: { | ||||||||||||||||||||||
| resident_key: "required", | ||||||||||||||||||||||
| user_verification: "required" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+301
to
+305
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # OR | ||||||||||||||||||||||
|
|
@@ -342,7 +354,7 @@ to be used in the client-side code to call `navigator.credentials.create({ "publ | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```ruby | ||||||||||||||||||||||
| creation_options = WebAuthn::Credential.options_for_create( | ||||||||||||||||||||||
| user: { id: user.webauthn_id, name: user.name } | ||||||||||||||||||||||
| user: { id: user.webauthn_id, name: user.name }, | ||||||||||||||||||||||
| exclude: user.credentials.map { |c| c.webauthn_id } | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.