Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ end

```ruby
# Generate and store the WebAuthn User ID the first time the user registers a credential
if !user.webauthn_id
user.update!(webauthn_id: WebAuthn.generate_user_id)
if !user.webauthn_user_handle
user.update!(webauthn_user_handle: WebAuthn.generate_user_id)
end

options = WebAuthn::Credential.options_for_create(
user: { id: user.webauthn_id, name: user.name },
exclude: user.credentials.map { |c| c.webauthn_id }
user: { id: user.webauthn_user_handle, name: user.name },
exclude: user.webauthn_credentials.map { |c| c.credential_id }
)

# Store the newly generated challenge somewhere so you can have it
Expand Down Expand Up @@ -207,8 +207,8 @@ begin
webauthn_credential.verify(session[:creation_challenge])

# Store Credential ID, Credential Public Key and Sign Count for future authentications
user.credentials.create!(
webauthn_id: webauthn_credential.id,
user.webauthn_credentials.create!(
credential_id: webauthn_credential.id,
public_key: webauthn_credential.public_key,
sign_count: webauthn_credential.sign_count
)
Expand All @@ -224,7 +224,7 @@ 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.webauthn_credentials.map { |c| c.credential_id })

# Store the newly generated challenge somewhere so you can have it
# for the verification phase.
Expand Down Expand Up @@ -254,7 +254,7 @@ attributes must be passed as keyword arguments to the `verify` method call.
# in params[:publicKeyCredential]:
webauthn_credential = WebAuthn::Credential.from_get(params[:publicKeyCredential])

stored_credential = user.credentials.find_by(webauthn_id: webauthn_credential.id)
stored_credential = user.webauthn_credentials.find_by(credential_id: webauthn_credential.id)

begin
webauthn_credential.verify(
Expand Down Expand Up @@ -288,16 +288,16 @@ Extensions can be requested in the initiation phase in both Credential Registrat
```ruby
# Credential Registration
creation_options = WebAuthn::Credential.options_for_create(
user: { id: user.webauthn_id, name: user.name },
exclude: user.credentials.map { |c| c.webauthn_id },
user: { id: user.webauthn_user_handle, name: user.name },
exclude: user.webauthn_credentials.map { |c| c.credential_id },
extensions: { appidExclude: domain.to_s }
)

# OR

# Credential Authentication
options = WebAuthn::Credential.options_for_get(
allow: user.credentials.map { |c| c.webauthn_id },
allow: user.webauthn_credentials.map { |c| c.credential_id },
extensions: { appid: domain.to_s }
)
```
Expand Down Expand Up @@ -342,8 +342,8 @@ 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 }
exclude: user.credentials.map { |c| c.webauthn_id }
user: { id: user.webauthn_user_handle, name: user.name }
exclude: user.webauthn_credentials.map { |c| c.credential_id }
)

# Store the newly generated challenge somewhere so you can have it
Expand All @@ -365,7 +365,7 @@ Helper method to build the necessary [PublicKeyCredentialRequestOptions](https:/
to be used in the client-side code to call `navigator.credentials.get({ "publicKey": publicKeyCredentialRequestOptions })`.

```ruby
request_options = WebAuthn::Credential.options_for_get(allow: user.credentials.map { |c| c.webauthn_id })
request_options = WebAuthn::Credential.options_for_get(allow: user.webauthn_credentials.map { |c| c.credential_id })

# Store the newly generated challenge somewhere so you can have it
# for the verification phase.
Expand Down