webauthn 2.0.0.beta1 → 2.0.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -6
- data/CHANGELOG.md +7 -6
- data/README.md +96 -5
- data/lib/webauthn/attestation_statement/base.rb +1 -1
- data/lib/webauthn/version.rb +1 -1
- data/webauthn.gemspec +2 -2
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd2d85eb0ce4769f5c4fe9529dedb4cd8bb25c4322bfb95bd4d9d623ab58b00
|
4
|
+
data.tar.gz: 6b0a3a7c524d7bd4db88d6c94968a165801374708ceac00f24e981c8599cbfe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebf401f24d784c4beb0adbcb98203de34612eb47bd6af002dc5cb02709bc258078ca92439d5917fef28f8ff869de6e02c41bbe3301f16f2472d76b0cf93662ec
|
7
|
+
data.tar.gz: 8e1d8f03cad6d75658c4116d7b6117539ba828cbfea07dbb9a584a29387f55519c9a8eed332b4602a75ed0d7691a9bd412e7f9241b9993b0dff123b69cec086c
|
data/.travis.yml
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
dist:
|
1
|
+
dist: bionic
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
|
5
5
|
rvm:
|
6
6
|
- ruby-head
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.4.7
|
7
|
+
- 2.6.5
|
8
|
+
- 2.5.7
|
9
|
+
- 2.4.9
|
11
10
|
- 2.3.8
|
12
11
|
|
13
12
|
gemfile:
|
@@ -20,7 +19,6 @@ matrix:
|
|
20
19
|
fast_finish: true
|
21
20
|
allow_failures:
|
22
21
|
- rvm: ruby-head
|
23
|
-
- rvm: 2.7.0-preview1
|
24
22
|
- gemfile: gemfiles/cose_head.gemfile
|
25
23
|
- gemfile: gemfiles/openssl_head.gemfile
|
26
24
|
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [v2.0.0
|
3
|
+
## [v2.0.0] - 2019-10-03
|
4
4
|
|
5
5
|
### Added
|
6
6
|
|
@@ -21,8 +21,9 @@
|
|
21
21
|
Please replace with `public_key:` and `sign_count:` keyword arguments. If you're not performing sign count
|
22
22
|
verification, signal opt-out with `sign_count: false`.
|
23
23
|
|
24
|
-
- `WebAuthn::FakeClient#create` and `WebAuthn::FakeClient#get` better fakes a real client by using
|
25
|
-
keys instead of snake_case symbol keys in the returned hash.
|
24
|
+
- `WebAuthn::FakeClient#create` and `WebAuthn::FakeClient#get` better fakes a real client by using lowerCamelCase
|
25
|
+
string keys instead of snake_case symbol keys in the returned hash.
|
26
|
+
|
26
27
|
- `WebAuthn::FakeClient#create` and `WebAuthn::FakeClient#get` better fakes a real client by not padding the
|
27
28
|
returned base64url-encoded `id` value.
|
28
29
|
|
@@ -45,8 +46,8 @@ pass it.
|
|
45
46
|
Please replace with `public_key:` and `sign_count:` keyword arguments. If you're not performing sign count
|
46
47
|
verification, signal opt-out with `sign_count: false`.
|
47
48
|
|
48
|
-
- `WebAuthn::FakeClient#create` and `WebAuthn::FakeClient#get` better fakes a real client by using
|
49
|
-
keys instead of snake_case symbol keys in the returned hash.
|
49
|
+
- `WebAuthn::FakeClient#create` and `WebAuthn::FakeClient#get` better fakes a real client by using lowerCamelCase
|
50
|
+
string keys instead of snake_case symbol keys in the returned hash.
|
50
51
|
|
51
52
|
- `WebAuthn::FakeClient#create` and `WebAuthn::FakeClient#get` better fakes a real client by not padding the
|
52
53
|
returned base64url-encoded `id` value.
|
@@ -260,7 +261,7 @@ Note: Both additions should help making it compatible with Chrome for Android 70
|
|
260
261
|
- `WebAuthn::AuthenticatorAttestationResponse.valid?` can be used to validate fido-u2f attestations returned by the browser
|
261
262
|
- Works with ruby 2.5
|
262
263
|
|
263
|
-
[v2.0.0
|
264
|
+
[v2.0.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.18.0...v2.0.0/
|
264
265
|
[v1.18.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.17.0...v1.18.0/
|
265
266
|
[v1.17.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.16.0...v1.17.0/
|
266
267
|
[v1.16.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.15.0...v1.16.0/
|
data/README.md
CHANGED
@@ -108,11 +108,11 @@ WebAuthn.configure do |config|
|
|
108
108
|
config.rp_name = "Example Inc."
|
109
109
|
|
110
110
|
# Optionally configure a client timeout hint, in milliseconds.
|
111
|
-
# This hint specifies how long the browser should wait for
|
112
|
-
#
|
111
|
+
# This hint specifies how long the browser should wait for any
|
112
|
+
# interaction with the user.
|
113
113
|
# This hint may be overridden by the browser.
|
114
114
|
# https://www.w3.org/TR/webauthn/#dom-publickeycredentialcreationoptions-timeout
|
115
|
-
config.credential_options_timeout =
|
115
|
+
# config.credential_options_timeout = 120_000
|
116
116
|
|
117
117
|
# You can optionally specify a different Relying Party ID
|
118
118
|
# (https://www.w3.org/TR/webauthn/#relying-party-identifier)
|
@@ -127,7 +127,12 @@ WebAuthn.configure do |config|
|
|
127
127
|
# used in your client-side (user agent) code before sending the credential to the server.
|
128
128
|
# Supported values: `:base64url` (default), `:base64` or `false` to disable all encoding.
|
129
129
|
#
|
130
|
-
# config.encoding =
|
130
|
+
# config.encoding = :base64url
|
131
|
+
|
132
|
+
# Possible values: "ES256", "ES384", "ES512", "PS256", "PS384", "PS512", "RS256", "RS384", "RS512", "RS1"
|
133
|
+
# Default: ["ES256", "PS256", "RS256"]
|
134
|
+
#
|
135
|
+
# config.algorithms << "ES384"
|
131
136
|
end
|
132
137
|
```
|
133
138
|
|
@@ -249,7 +254,93 @@ end
|
|
249
254
|
|
250
255
|
## API
|
251
256
|
|
252
|
-
|
257
|
+
#### `WebAuthn.generate_user_id`
|
258
|
+
|
259
|
+
Generates a [WebAuthn User Handle](https://www.w3.org/TR/webauthn-2/#user-handle) that follows the WebAuthn spec recommendations.
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
WebAuthn.generate_user_id # "lWoMZTGf_ml2RoY5qPwbwrkxrvTqWjGOxEoYBgxft3zG-LlrICvE-y8bxFi06zMyIOyNsJoWx4Fa2TOqoRmnxA"
|
263
|
+
```
|
264
|
+
|
265
|
+
#### `WebAuthn::Credential.options_for_create(options)`
|
266
|
+
|
267
|
+
Helper method to build the necessary [PublicKeyCredentialCreationOptions](https://www.w3.org/TR/webauthn-2/#dictdef-publickeycredentialcreationoptions)
|
268
|
+
to be used in the client-side code to call `navigator.credentials.create({ "publicKey": publicKeyCredentialCreationOptions })`.
|
269
|
+
|
270
|
+
```ruby
|
271
|
+
creation_options = WebAuthn::Credential.options_for_create(
|
272
|
+
user: { id: user.webauthn_id, name: user.name }
|
273
|
+
exclude: user.credentials.map { |c| c.webauthn_id }
|
274
|
+
)
|
275
|
+
|
276
|
+
# Store the newly generated challenge somewhere so you can have it
|
277
|
+
# for the verification phase.
|
278
|
+
session[:creation_challenge] = creation_options.challenge
|
279
|
+
|
280
|
+
# Send `creation_options` back to the browser, so that they can be used
|
281
|
+
# to call `navigator.credentials.create({ "publicKey": creationOptions })`
|
282
|
+
#
|
283
|
+
# You can call `creation_options.as_json` to get a ruby hash with a JSON representation if needed.
|
284
|
+
|
285
|
+
# If inside a Rails controller, `render json: creation_options` will just work.
|
286
|
+
# I.e. it will encode and convert the options to JSON automatically.
|
287
|
+
```
|
288
|
+
|
289
|
+
#### `WebAuthn::Credential.options_for_get([options])`
|
290
|
+
|
291
|
+
Helper method to build the necessary [PublicKeyCredentialRequestOptions](https://www.w3.org/TR/webauthn-2/#dictdef-publickeycredentialrequestoptions)
|
292
|
+
to be used in the client-side code to call `navigator.credentials.get({ "publicKey": publicKeyCredentialRequestOptions })`.
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
request_options = WebAuthn::Credential.options_for_get(allow: user.credentials.map { |c| c.webauthn_id })
|
296
|
+
|
297
|
+
# Store the newly generated challenge somewhere so you can have it
|
298
|
+
# for the verification phase.
|
299
|
+
session[:authentication_challenge] = request_options.challenge
|
300
|
+
|
301
|
+
# Send `request_options` back to the browser, so that they can be used
|
302
|
+
# to call `navigator.credentials.get({ "publicKey": requestOptions })`
|
303
|
+
|
304
|
+
# You can call `request_options.as_json` to get a ruby hash with a JSON representation if needed.
|
305
|
+
|
306
|
+
# If inside a Rails controller, `render json: request_options` will just work.
|
307
|
+
# I.e. it will encode and convert the options to JSON automatically.
|
308
|
+
```
|
309
|
+
|
310
|
+
#### `WebAuthn::Credential.from_create(credential_create_result)`
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
credential_with_attestation = WebAuthn::Credential.from_create(params[:publicKeyCredential])
|
314
|
+
```
|
315
|
+
|
316
|
+
#### `WebAuthn::Credential.from_get(credential_get_result)`
|
317
|
+
|
318
|
+
```ruby
|
319
|
+
credential_with_assertion = WebAuthn::Credential.from_get(params[:publicKeyCredential])
|
320
|
+
```
|
321
|
+
|
322
|
+
#### `PublicKeyCredentialWithAttestation#verify(challenge)`
|
323
|
+
|
324
|
+
Verifies the created WebAuthn credential is [valid](https://www.w3.org/TR/webauthn-2/#sctn-registering-a-new-credential).
|
325
|
+
|
326
|
+
```ruby
|
327
|
+
credential_with_attestation.verify(session[:creation_challenge])
|
328
|
+
```
|
329
|
+
|
330
|
+
#### `PublicKeyCredentialWithAssertion#verify(challenge, public_key:, sign_count:)`
|
331
|
+
|
332
|
+
Verifies the asserted WebAuthn credential is [valid](https://www.w3.org/TR/webauthn-2/#sctn-verifying-assertion).
|
333
|
+
|
334
|
+
Mainly, that the client provided a valid cryptographic signature for the corresponding stored credential public
|
335
|
+
key, among other extra validations.
|
336
|
+
|
337
|
+
```ruby
|
338
|
+
credential_with_assertion.verify(
|
339
|
+
session[:authentication_challenge],
|
340
|
+
public_key: stored_credential.public_key,
|
341
|
+
sign_count: stored_credential.sign_count
|
342
|
+
)
|
343
|
+
```
|
253
344
|
|
254
345
|
## Attestation Statement Formats
|
255
346
|
|
data/lib/webauthn/version.rb
CHANGED
data/webauthn.gemspec
CHANGED
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency "appraisal", "~> 2.2.0"
|
43
43
|
spec.add_development_dependency "bundler", ">= 1.17", "< 3.0"
|
44
44
|
spec.add_development_dependency "byebug", "~> 11.0"
|
45
|
-
spec.add_development_dependency "rake", "~>
|
45
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
46
46
|
spec.add_development_dependency "rspec", "~> 3.8"
|
47
|
-
spec.add_development_dependency "rubocop", "0.
|
47
|
+
spec.add_development_dependency "rubocop", "0.75.0"
|
48
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webauthn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gonzalo Rodriguez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: awrence
|
@@ -169,14 +169,14 @@ dependencies:
|
|
169
169
|
requirements:
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '
|
172
|
+
version: '13.0'
|
173
173
|
type: :development
|
174
174
|
prerelease: false
|
175
175
|
version_requirements: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: '
|
179
|
+
version: '13.0'
|
180
180
|
- !ruby/object:Gem::Dependency
|
181
181
|
name: rspec
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,14 +197,14 @@ dependencies:
|
|
197
197
|
requirements:
|
198
198
|
- - '='
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: 0.
|
200
|
+
version: 0.75.0
|
201
201
|
type: :development
|
202
202
|
prerelease: false
|
203
203
|
version_requirements: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
205
|
- - '='
|
206
206
|
- !ruby/object:Gem::Version
|
207
|
-
version: 0.
|
207
|
+
version: 0.75.0
|
208
208
|
description: |-
|
209
209
|
WebAuthn ruby server library ― Make your application a W3C Web Authentication conformant
|
210
210
|
Relying Party and allow your users to authenticate with U2F and FIDO2 authenticators.
|
@@ -309,11 +309,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
309
|
version: '2.3'
|
310
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
311
|
requirements:
|
312
|
-
- - "
|
312
|
+
- - ">="
|
313
313
|
- !ruby/object:Gem::Version
|
314
|
-
version:
|
314
|
+
version: '0'
|
315
315
|
requirements: []
|
316
|
-
rubygems_version: 3.0.
|
316
|
+
rubygems_version: 3.0.3
|
317
317
|
signing_key:
|
318
318
|
specification_version: 4
|
319
319
|
summary: WebAuthn ruby server library
|