webauthn 3.4.3 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -38,7 +38,7 @@ _More_: [SECURITY](SECURITY.md)
38
38
 
39
39
  ### What is WebAuthn?
40
40
 
41
- WebAuthn (Web Authentication) is a W3C standard for secure public-key authentication on the Web supported by all leading browsers and platforms.
41
+ WebAuthn (Web Authentication) is a W3C standard for secure public-key authentication on the Web supported by all leading browsers and platforms. WebAuthn is the standard that underpins passkeys, the phishing-resistant replacement for passwords.
42
42
 
43
43
  #### Good Intros
44
44
 
@@ -86,7 +86,7 @@ Or install it yourself as:
86
86
 
87
87
  ## Usage
88
88
 
89
- You can find a working example on how to use this gem in a pasword-less login in a __Rails__ app in [webauthn-rails-demo-app](https://github.com/cedarcode/webauthn-rails-demo-app). If you want to see an example on how to use this gem as a second factor authenticator in a __Rails__ application instead, you can check it in [webauthn-2fa-rails-demo](https://github.com/cedarcode/webauthn-2fa-rails-demo).
89
+ You can find a working example on how to use this gem in a passwordless login in a __Rails__ app in [webauthn-rails-demo-app](https://github.com/cedarcode/webauthn-rails-demo-app). If you want to see an example on how to use this gem as a second factor authenticator in a __Rails__ application instead, you can check it in [webauthn-2fa-rails-demo](https://github.com/cedarcode/webauthn-2fa-rails-demo).
90
90
 
91
91
  If you are migrating an existing application from the legacy FIDO U2F JavaScript API to WebAuthn, also refer to
92
92
  [`docs/u2f_migration.md`](docs/u2f_migration.md).
@@ -104,6 +104,31 @@ WebAuthn.configure do |config|
104
104
  # Multiple origins can be used when needed. Using more than one will imply you MUST configure rp_id explicitely. If you need your credentials to be bound to a single origin but you have more than one tenant, please see [our Advanced Configuration section](https://github.com/cedarcode/webauthn-ruby/blob/master/docs/advanced_configuration.md) instead of adding multiple origins.
105
105
  config.allowed_origins = ["https://auth.example.com"]
106
106
 
107
+ # When operating within iframes or embedded contexts, you may need to restrict
108
+ # which top-level origins are permitted to host WebAuthn ceremonies.
109
+ #
110
+ # crossOrigin / topOrigin verification is DISABLED by default:
111
+ # config.verify_cross_origin = false
112
+ #
113
+ # When `verify_cross_origin` is false, any `crossOrigin` / `topOrigin` values reported by the browser
114
+ # are ignored. As a result, credentials created or used within a cross-origin iframe will be treated
115
+ # as valid.
116
+ #
117
+ # When `verify_cross_origin` is true, you can either:
118
+ #
119
+ # (A) Allow only specific top-level origins to embed your ceremony
120
+ # (each entry must match the browser-reported `topOrigin` during registration/authentication):
121
+ #
122
+ # config.allowed_top_origins = ["https://app.example.com"]
123
+ #
124
+ # (B) Forbid ANY cross-origin iframe usage altogether
125
+ # (this rejects creation/authentication whenever `crossOrigin` is true):
126
+ #
127
+ # config.allowed_top_origins = []
128
+ #
129
+ # Note: if `verify_cross_origin` is not enabled, any values set in `allowed_top_origins`
130
+ # will be ignored.
131
+
107
132
  # Relying Party name for display purposes
108
133
  config.rp_name = "Example Inc."
109
134
 
@@ -112,7 +137,7 @@ WebAuthn.configure do |config|
112
137
  # interaction with the user.
113
138
  # This hint may be overridden by the browser.
114
139
  # https://www.w3.org/TR/webauthn/#dom-publickeycredentialcreationoptions-timeout
115
- # config.credential_options_timeout = 120_000
140
+ # config.credential_options_timeout = 300_000
116
141
 
117
142
  # You can optionally specify a different Relying Party ID
118
143
  # (https://www.w3.org/TR/webauthn/#relying-party-identifier)
@@ -144,14 +169,18 @@ end
144
169
  #### Initiation phase
145
170
 
146
171
  ```ruby
147
- # Generate and store the WebAuthn User ID the first time the user registers a credential
148
- if !user.webauthn_id
149
- user.update!(webauthn_id: WebAuthn.generate_user_id)
172
+ # Generate and store the WebAuthn User Handle the first time the user registers a credential
173
+ if !user.webauthn_user_handle
174
+ user.update!(webauthn_user_handle: WebAuthn.generate_user_handle)
150
175
  end
151
176
 
152
177
  options = WebAuthn::Credential.options_for_create(
153
- user: { id: user.webauthn_id, name: user.name },
154
- exclude: user.credentials.map { |c| c.webauthn_id }
178
+ user: { id: user.webauthn_user_handle, name: user.name },
179
+ exclude: user.webauthn_credentials.map { |c| c.webauthn_id },
180
+ authenticator_selection: {
181
+ resident_key: "discouraged", # For a passwordless login or 2FA. Use "required" for a passkey-based (passwordless and usernameless) login.
182
+ user_verification: "required" # For a passwordless or passkey-based (passwordless and usernameless) login. Use "discouraged" for 2FA.
183
+ }
155
184
  )
156
185
 
157
186
  # Store the newly generated challenge somewhere so you can have it
@@ -166,23 +195,24 @@ session[:creation_challenge] = options.challenge
166
195
  # If inside a Rails controller, `render json: options` will just work.
167
196
  # I.e. it will encode and convert the options to JSON automatically.
168
197
 
169
- # For your frontend code, you might find @github/webauthn-json npm package useful.
170
- # Especially for handling the necessary decoding of the options, and sending the
171
- # `PublicKeyCredential` object back to the server.
198
+ # For your frontend code, you might find the [built-in browser methods](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential) useful.
199
+ # The built-in `PublicKeyCredential.parseCreationOptionsFromJSON(options)` allows you to decode the options,
200
+ # and the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back to the server.
172
201
  ```
173
202
 
174
203
  #### Verification phase
175
204
 
176
205
  ```ruby
177
- # Assuming you're using @github/webauthn-json package to send the `PublicKeyCredential` object back
206
+ # Assuming you're using the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back
178
207
  # in params[:publicKeyCredential]:
179
208
  webauthn_credential = WebAuthn::Credential.from_create(params[:publicKeyCredential])
180
209
 
181
210
  begin
182
- webauthn_credential.verify(session[:creation_challenge])
211
+ # Enforce user verification (pairs with the "required" request above). Omit for 2FA.
212
+ webauthn_credential.verify(session[:creation_challenge], user_verification: true)
183
213
 
184
214
  # Store Credential ID, Credential Public Key and Sign Count for future authentications
185
- user.credentials.create!(
215
+ user.webauthn_credentials.create!(
186
216
  webauthn_id: webauthn_credential.id,
187
217
  public_key: webauthn_credential.public_key,
188
218
  sign_count: webauthn_credential.sign_count
@@ -199,7 +229,12 @@ end
199
229
  #### Initiation phase
200
230
 
201
231
  ```ruby
202
- options = WebAuthn::Credential.options_for_get(allow: user.credentials.map { |c| c.webauthn_id })
232
+ options = WebAuthn::Credential.options_for_get(
233
+ # Pass `allow` when the user is already known (passwordless/2FA/reauth).
234
+ # For a passkey-based (usernameless and passwordless) login, omit it and resolve the user from `user_handle` after `from_get`.
235
+ allow: user.webauthn_credentials.map { |c| c.webauthn_id },
236
+ user_verification: "required" # For a passwordless or passkey-based (passwordless and usernameless) login. Use "discouraged" for 2FA.
237
+ )
203
238
 
204
239
  # Store the newly generated challenge somewhere so you can have it
205
240
  # for the verification phase.
@@ -213,9 +248,9 @@ session[:authentication_challenge] = options.challenge
213
248
  # If inside a Rails controller, `render json: options` will just work.
214
249
  # I.e. it will encode and convert the options to JSON automatically.
215
250
 
216
- # For your frontend code, you might find @github/webauthn-json npm package useful.
217
- # Especially for handling the necessary decoding of the options, and sending the
218
- # `PublicKeyCredential` object back to the server.
251
+ # For your frontend code, you might find the [built-in browser methods](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential) useful.
252
+ # The built-in `PublicKeyCredential.parseRequestOptionsFromJSON(options)` allows you to decode the options,
253
+ # and the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back to the server.
219
254
  ```
220
255
 
221
256
  #### Verification phase
@@ -225,17 +260,18 @@ interface returned by the browser to the stored `credential_id`. The correspondi
225
260
  attributes must be passed as keyword arguments to the `verify` method call.
226
261
 
227
262
  ```ruby
228
- # Assuming you're using @github/webauthn-json package to send the `PublicKeyCredential` object back
263
+ # Assuming you're using the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back
229
264
  # in params[:publicKeyCredential]:
230
265
  webauthn_credential = WebAuthn::Credential.from_get(params[:publicKeyCredential])
231
266
 
232
- stored_credential = user.credentials.find_by(webauthn_id: webauthn_credential.id)
267
+ stored_credential = user.webauthn_credentials.find_by(webauthn_id: webauthn_credential.id)
233
268
 
234
269
  begin
235
270
  webauthn_credential.verify(
236
271
  session[:authentication_challenge],
237
272
  public_key: stored_credential.public_key,
238
- sign_count: stored_credential.sign_count
273
+ sign_count: stored_credential.sign_count,
274
+ user_verification: true # For a passwordless or passkey-based (passwordless and usernameless) login. Omit for 2FA.
239
275
  )
240
276
 
241
277
  # Update the stored credential sign count with the value from `webauthn_credential.sign_count`
@@ -263,16 +299,20 @@ Extensions can be requested in the initiation phase in both Credential Registrat
263
299
  ```ruby
264
300
  # Credential Registration
265
301
  creation_options = WebAuthn::Credential.options_for_create(
266
- user: { id: user.webauthn_id, name: user.name },
267
- exclude: user.credentials.map { |c| c.webauthn_id },
268
- extensions: { appidExclude: domain.to_s }
302
+ user: { id: user.webauthn_user_handle, name: user.name },
303
+ exclude: user.webauthn_credentials.map { |c| c.webauthn_id },
304
+ extensions: { appidExclude: domain.to_s },
305
+ authenticator_selection: {
306
+ resident_key: "discouraged", # For a passwordless login or 2FA. Use "required" for a passkey-based (passwordless and usernameless) login.
307
+ user_verification: "required" # For a passwordless or passkey-based (passwordless and usernameless) login. Use "discouraged" for 2FA.
308
+ }
269
309
  )
270
310
 
271
311
  # OR
272
312
 
273
313
  # Credential Authentication
274
314
  options = WebAuthn::Credential.options_for_get(
275
- allow: user.credentials.map { |c| c.webauthn_id },
315
+ allow: user.webauthn_credentials.map { |c| c.webauthn_id },
276
316
  extensions: { appid: domain.to_s }
277
317
  )
278
318
  ```
@@ -302,14 +342,16 @@ A list of all currently defined extensions:
302
342
 
303
343
  ## API
304
344
 
305
- #### `WebAuthn.generate_user_id`
345
+ #### `WebAuthn.generate_user_handle`
306
346
 
307
347
  Generates a [WebAuthn User Handle](https://www.w3.org/TR/webauthn-2/#user-handle) that follows the WebAuthn spec recommendations.
308
348
 
309
349
  ```ruby
310
- WebAuthn.generate_user_id # "lWoMZTGf_ml2RoY5qPwbwrkxrvTqWjGOxEoYBgxft3zG-LlrICvE-y8bxFi06zMyIOyNsJoWx4Fa2TOqoRmnxA"
350
+ WebAuthn.generate_user_handle # "lWoMZTGf_ml2RoY5qPwbwrkxrvTqWjGOxEoYBgxft3zG-LlrICvE-y8bxFi06zMyIOyNsJoWx4Fa2TOqoRmnxA"
311
351
  ```
312
352
 
353
+ > `WebAuthn.generate_user_id` is also available as an alias.
354
+
313
355
  #### `WebAuthn::Credential.options_for_create(options)`
314
356
 
315
357
  Helper method to build the necessary [PublicKeyCredentialCreationOptions](https://www.w3.org/TR/webauthn-2/#dictdef-publickeycredentialcreationoptions)
@@ -317,8 +359,8 @@ to be used in the client-side code to call `navigator.credentials.create({ "publ
317
359
 
318
360
  ```ruby
319
361
  creation_options = WebAuthn::Credential.options_for_create(
320
- user: { id: user.webauthn_id, name: user.name }
321
- exclude: user.credentials.map { |c| c.webauthn_id }
362
+ user: { id: user.webauthn_user_handle, name: user.name },
363
+ exclude: user.webauthn_credentials.map { |c| c.webauthn_id }
322
364
  )
323
365
 
324
366
  # Store the newly generated challenge somewhere so you can have it
@@ -340,7 +382,7 @@ Helper method to build the necessary [PublicKeyCredentialRequestOptions](https:/
340
382
  to be used in the client-side code to call `navigator.credentials.get({ "publicKey": publicKeyCredentialRequestOptions })`.
341
383
 
342
384
  ```ruby
343
- request_options = WebAuthn::Credential.options_for_get(allow: user.credentials.map { |c| c.webauthn_id })
385
+ request_options = WebAuthn::Credential.options_for_get(allow: user.webauthn_credentials.map { |c| c.webauthn_id })
344
386
 
345
387
  # Store the newly generated challenge somewhere so you can have it
346
388
  # for the verification phase.
@@ -32,7 +32,7 @@ Instead of the [Global Configuration](../README.md#configuration) you place in `
32
32
  # interaction with the user.
33
33
  # This hint may be overridden by the browser.
34
34
  # https://www.w3.org/TR/webauthn/#dom-publickeycredentialcreationoptions-timeout
35
- # credential_options_timeout: 120_000
35
+ # credential_options_timeout: 300_000
36
36
 
37
37
  # You can optionally specify a different Relying Party ID
38
38
  # (https://www.w3.org/TR/webauthn/#relying-party-identifier)
@@ -58,8 +58,6 @@ Instead of the [Global Configuration](../README.md#configuration) you place in `
58
58
 
59
59
  ## Instance Based API
60
60
 
61
- **DISCLAIMER: This API was released on version 3.0.0.alpha1 and is still under evaluation. Although it has been thoroughly tested and it is fully functional it might be changed until the final release of version 3.0.0.**
62
-
63
61
  The explanation for each ceremony can be found in depth in [Credential Registration](../README.md#credential-registration) and [Credential Authentication](../README.md#credential-authentication) but if you choose this instance based approach to define your WebAuthn configurations and assuming `relying_party` is the result of an instance you get through `WebAuthn::RelyingParty.new(...)` the code in those explanations needs to be updated to:
64
62
 
65
63
  ### Credential Registration
@@ -13,10 +13,13 @@ require "webauthn/encoder"
13
13
  module WebAuthn
14
14
  class AttestationStatementVerificationError < VerificationError; end
15
15
  class AttestedCredentialVerificationError < VerificationError; end
16
+ class CredentialIdLengthVerificationError < VerificationError; end
16
17
 
17
18
  class AuthenticatorAttestationResponse < AuthenticatorResponse
18
19
  extend Forwardable
19
20
 
21
+ MAX_CREDENTIAL_ID_LENGTH = 1023
22
+
20
23
  def self.from_client(response, relying_party: WebAuthn.configuration.relying_party)
21
24
  encoder = relying_party.encoder
22
25
 
@@ -45,6 +48,7 @@ module WebAuthn
45
48
  if relying_party.verify_attestation_statement
46
49
  verify_item(:attestation_statement)
47
50
  end
51
+ verify_item(:credential_id_length)
48
52
 
49
53
  true
50
54
  end
@@ -80,5 +84,9 @@ module WebAuthn
80
84
  def valid_attestation_statement?
81
85
  @attestation_type, @attestation_trust_path = attestation_object.valid_attestation_statement?(client_data.hash)
82
86
  end
87
+
88
+ def valid_credential_id_length?
89
+ authenticator_data.credential.id.bytesize <= MAX_CREDENTIAL_ID_LENGTH
90
+ end
83
91
  end
84
92
  end
@@ -10,10 +10,11 @@ module WebAuthn
10
10
  class VerificationError < Error; end
11
11
 
12
12
  class AuthenticatorDataVerificationError < VerificationError; end
13
+ class BackupFlagsVerificationError < VerificationError; end
13
14
  class ChallengeVerificationError < VerificationError; end
14
15
  class OriginVerificationError < VerificationError; end
15
16
  class RpIdVerificationError < VerificationError; end
16
- class TokenBindingVerificationError < VerificationError; end
17
+ class TopOriginVerificationError < VerificationError; end
17
18
  class TypeVerificationError < VerificationError; end
18
19
  class UserPresenceVerificationError < VerificationError; end
19
20
  class UserVerifiedVerificationError < VerificationError; end
@@ -30,9 +31,9 @@ module WebAuthn
30
31
  rp_id ||= relying_party.id
31
32
 
32
33
  verify_item(:type)
33
- verify_item(:token_binding)
34
34
  verify_item(:challenge, expected_challenge)
35
35
  verify_item(:origin, expected_origin)
36
+ verify_item(:top_origin) if needs_top_origin_verification?
36
37
  verify_item(:authenticator_data)
37
38
 
38
39
  verify_item(
@@ -49,6 +50,8 @@ module WebAuthn
49
50
  verify_item(:user_verified)
50
51
  end
51
52
 
53
+ verify_item(:backup_flags)
54
+
52
55
  true
53
56
  end
54
57
 
@@ -80,8 +83,10 @@ module WebAuthn
80
83
  client_data.type == type
81
84
  end
82
85
 
83
- def valid_token_binding?
84
- client_data.valid_token_binding_format?
86
+ def valid_top_origin?
87
+ return false unless client_data.cross_origin
88
+
89
+ relying_party.allowed_top_origins&.include?(client_data.top_origin)
85
90
  end
86
91
 
87
92
  def valid_challenge?(expected_challenge)
@@ -114,6 +119,10 @@ module WebAuthn
114
119
  authenticator_data.user_verified?
115
120
  end
116
121
 
122
+ def valid_backup_flags?
123
+ authenticator_data.credential_backup_eligible? || !authenticator_data.credential_backed_up?
124
+ end
125
+
117
126
  def rp_id_from_origin(expected_origin)
118
127
  URI.parse(expected_origin.first).host if expected_origin.size == 1
119
128
  end
@@ -121,5 +130,9 @@ module WebAuthn
121
130
  def type
122
131
  raise NotImplementedError, "Please define #type method in subclass"
123
132
  end
133
+
134
+ def needs_top_origin_verification?
135
+ relying_party.verify_cross_origin && (client_data.cross_origin || client_data.top_origin)
136
+ end
124
137
  end
125
138
  end
@@ -9,8 +9,6 @@ module WebAuthn
9
9
  class ClientDataMissingError < Error; end
10
10
 
11
11
  class ClientData
12
- VALID_TOKEN_BINDING_STATUSES = ["present", "supported", "not-supported"].freeze
13
-
14
12
  def initialize(client_data_json)
15
13
  @client_data_json = client_data_json
16
14
  end
@@ -27,16 +25,12 @@ module WebAuthn
27
25
  data["origin"]
28
26
  end
29
27
 
30
- def token_binding
31
- data["tokenBinding"]
28
+ def cross_origin
29
+ data["crossOrigin"]
32
30
  end
33
31
 
34
- def valid_token_binding_format?
35
- if token_binding
36
- token_binding.is_a?(Hash) && VALID_TOKEN_BINDING_STATUSES.include?(token_binding["status"])
37
- else
38
- true
39
- end
32
+ def top_origin
33
+ data["topOrigin"]
40
34
  end
41
35
 
42
36
  def hash
@@ -24,8 +24,12 @@ module WebAuthn
24
24
  :origin=,
25
25
  :allowed_origins,
26
26
  :allowed_origins=,
27
+ :allowed_top_origins,
28
+ :allowed_top_origins=,
27
29
  :verify_attestation_statement,
28
30
  :verify_attestation_statement=,
31
+ :verify_cross_origin,
32
+ :verify_cross_origin=,
29
33
  :credential_options_timeout,
30
34
  :credential_options_timeout=,
31
35
  :silent_authentication,
@@ -10,16 +10,18 @@ module WebAuthn
10
10
  class FakeClient
11
11
  TYPES = { create: "webauthn.create", get: "webauthn.get" }.freeze
12
12
 
13
- attr_reader :origin, :token_binding, :encoding
13
+ attr_reader :origin, :cross_origin, :top_origin, :encoding
14
14
 
15
15
  def initialize(
16
16
  origin = fake_origin,
17
- token_binding: nil,
17
+ cross_origin: nil,
18
+ top_origin: nil,
18
19
  authenticator: WebAuthn::FakeAuthenticator.new,
19
20
  encoding: WebAuthn.configuration.encoding
20
21
  )
21
22
  @origin = origin
22
- @token_binding = token_binding
23
+ @cross_origin = cross_origin
24
+ @top_origin = top_origin
23
25
  @authenticator = authenticator
24
26
  @encoding = encoding
25
27
  end
@@ -81,7 +83,7 @@ module WebAuthn
81
83
  user_present: true,
82
84
  user_verified: false,
83
85
  backup_eligibility: false,
84
- backup_state: true,
86
+ backup_state: false,
85
87
  sign_count: nil,
86
88
  extensions: nil,
87
89
  user_handle: nil,
@@ -133,8 +135,12 @@ module WebAuthn
133
135
  origin: origin
134
136
  }
135
137
 
136
- if token_binding
137
- data[:tokenBinding] = token_binding
138
+ if cross_origin
139
+ data[:crossOrigin] = cross_origin
140
+ end
141
+
142
+ if top_origin
143
+ data[:topOrigin] = top_origin
138
144
  end
139
145
 
140
146
  data.to_json
@@ -10,6 +10,7 @@ module WebAuthn
10
10
  class CreationOptions < Options
11
11
  attr_accessor(
12
12
  :attestation,
13
+ :attestation_formats,
13
14
  :authenticator_selection,
14
15
  :exclude,
15
16
  :algs,
@@ -19,6 +20,7 @@ module WebAuthn
19
20
 
20
21
  def initialize(
21
22
  attestation: nil,
23
+ attestation_formats: nil,
22
24
  authenticator_selection: nil,
23
25
  exclude_credentials: nil,
24
26
  exclude: nil,
@@ -31,6 +33,7 @@ module WebAuthn
31
33
  super(**keyword_arguments)
32
34
 
33
35
  @attestation = attestation
36
+ @attestation_formats = attestation_formats
34
37
  @authenticator_selection = authenticator_selection
35
38
  @exclude_credentials = exclude_credentials
36
39
  @exclude = exclude
@@ -39,6 +42,7 @@ module WebAuthn
39
42
 
40
43
  @rp =
41
44
  if rp.is_a?(Hash)
45
+ rp = rp.dup
42
46
  rp[:name] ||= relying_party.name
43
47
  rp[:id] ||= relying_party.id
44
48
 
@@ -66,7 +70,10 @@ module WebAuthn
66
70
  private
67
71
 
68
72
  def attributes
69
- super.concat([:rp, :user, :pub_key_cred_params, :attestation, :authenticator_selection, :exclude_credentials])
73
+ super.concat(
74
+ [:rp, :user, :pub_key_cred_params, :attestation, :attestation_formats, :authenticator_selection,
75
+ :exclude_credentials]
76
+ )
70
77
  end
71
78
 
72
79
  def exclude_credentials_from_exclude
@@ -9,12 +9,13 @@ module WebAuthn
9
9
 
10
10
  CHALLENGE_LENGTH = 32
11
11
 
12
- attr_reader :timeout, :extensions, :relying_party
12
+ attr_reader :timeout, :extensions, :hints, :relying_party
13
13
 
14
- def initialize(timeout: nil, extensions: nil, relying_party: WebAuthn.configuration.relying_party)
14
+ def initialize(timeout: nil, extensions: nil, hints: nil, relying_party: WebAuthn.configuration.relying_party)
15
15
  @relying_party = relying_party
16
16
  @timeout = timeout || default_timeout
17
17
  @extensions = default_extensions.merge(extensions || {})
18
+ @hints = hints
18
19
  end
19
20
 
20
21
  def challenge
@@ -24,7 +25,7 @@ module WebAuthn
24
25
  private
25
26
 
26
27
  def attributes
27
- [:challenge, :timeout, :extensions]
28
+ [:challenge, :timeout, :extensions, :hints]
28
29
  end
29
30
 
30
31
  def encoder
@@ -19,11 +19,13 @@ module WebAuthn
19
19
  algorithms: DEFAULT_ALGORITHMS.dup,
20
20
  encoding: WebAuthn::Encoder::STANDARD_ENCODING,
21
21
  allowed_origins: nil,
22
+ allowed_top_origins: nil,
22
23
  origin: nil,
23
24
  id: nil,
24
25
  name: nil,
25
26
  verify_attestation_statement: true,
26
- credential_options_timeout: 120000,
27
+ verify_cross_origin: false,
28
+ credential_options_timeout: 300_000,
27
29
  silent_authentication: false,
28
30
  acceptable_attestation_types: ['None', 'Self', 'Basic', 'AttCA', 'Basic_or_AttCA', 'AnonCA'],
29
31
  attestation_root_certificates_finders: [],
@@ -32,9 +34,11 @@ module WebAuthn
32
34
  @algorithms = algorithms
33
35
  @encoding = encoding
34
36
  @allowed_origins = allowed_origins
37
+ @allowed_top_origins = allowed_top_origins
35
38
  @id = id
36
39
  @name = name
37
40
  @verify_attestation_statement = verify_attestation_statement
41
+ @verify_cross_origin = verify_cross_origin
38
42
  @credential_options_timeout = credential_options_timeout
39
43
  @silent_authentication = silent_authentication
40
44
  @acceptable_attestation_types = acceptable_attestation_types
@@ -46,9 +50,11 @@ module WebAuthn
46
50
  attr_accessor :algorithms,
47
51
  :encoding,
48
52
  :allowed_origins,
53
+ :allowed_top_origins,
49
54
  :id,
50
55
  :name,
51
56
  :verify_attestation_statement,
57
+ :verify_cross_origin,
52
58
  :credential_options_timeout,
53
59
  :silent_authentication,
54
60
  :acceptable_attestation_types,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebAuthn
4
- VERSION = "3.4.3"
4
+ VERSION = "3.5.1"
5
5
  end
data/lib/webauthn.rb CHANGED
@@ -10,7 +10,10 @@ require "webauthn/version"
10
10
  module WebAuthn
11
11
  TYPE_PUBLIC_KEY = "public-key"
12
12
 
13
- def self.generate_user_id
14
- configuration.encoder.encode(SecureRandom.random_bytes(64))
13
+ class << self
14
+ def generate_user_id
15
+ configuration.encoder.encode(SecureRandom.random_bytes(64))
16
+ end
17
+ alias_method :generate_user_handle, :generate_user_id
15
18
  end
16
19
  end
data/webauthn.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = "WebAuthn ruby server library"
14
14
  spec.description = 'WebAuthn ruby server library ― Make your application a W3C Web Authentication conformant
15
- Relying Party and allow your users to authenticate with U2F and FIDO2 authenticators.'
15
+ Relying Party and allow your users to authenticate with FIDO2/U2F authenticators as passkeys or security keys.'
16
16
  spec.homepage = "https://github.com/cedarcode/webauthn-ruby"
17
17
  spec.license = "MIT"
18
18
 
@@ -35,13 +35,13 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_dependency "android_key_attestation", "~> 0.3.0"
37
37
  spec.add_dependency "bindata", "~> 2.4"
38
- spec.add_dependency "cbor", "~> 0.5.9"
39
- spec.add_dependency "cose", "~> 1.1"
38
+ spec.add_dependency "cbor", "~> 0.6.2.2"
39
+ spec.add_dependency "cose", "~> 1.4"
40
40
  spec.add_dependency "openssl", ">= 2.2"
41
41
  spec.add_dependency "safety_net_attestation", "~> 0.5.0"
42
42
  spec.add_dependency "tpm-key_attestation", "~> 0.14.0"
43
43
 
44
- spec.add_development_dependency "bundler", ">= 1.17", "< 3.0"
44
+ spec.add_development_dependency "bundler", ">= 1.17", "< 5.0"
45
45
  spec.add_development_dependency "byebug", "~> 11.0"
46
46
  spec.add_development_dependency "rake", "~> 13.0"
47
47
  spec.add_development_dependency "rspec", "~> 3.8"