webauthn 3.4.4 → 3.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df6bf3fafae0bdb5587fa25d53cd83c0af43d798a98fd25118d1a1645e140a99
4
- data.tar.gz: 70fe4568f2c04990884f3caf4fc89a531378ee77e6ab158879c311f6107305ff
3
+ metadata.gz: a20be10512baef48a31bf98b85727c8819a9b7c995400bad6282648e2120695e
4
+ data.tar.gz: b84352d26add2af3477070c91ef5707134882f99810216d89f09f9c81e1ef909
5
5
  SHA512:
6
- metadata.gz: bcac5a28dd08da1194eb05357d29a003a9dd520db2a7e961ec4024795858473e295dc2ee13eacf0196f067fef35267a240454c1419e39b0585a69222fdc76048
7
- data.tar.gz: bca37ca9238d993e8e4d99448d5a8f11325e67333acab372fd2ba6b4719e9df0a9952dc9bbb4ef1686ca458b419a74d9689fae0124f7ea7dc19757006434aaa4
6
+ metadata.gz: cf7e5872c96bcca1af15245515fa9de6fc89d677e1bf85a0dbced0768e820dddbf7d74d0a1b95b369b1bbe89dcad1cbef453d904d295e1e3ca25326f4b159bce
7
+ data.tar.gz: 58d19414843c25daf60199ed74e3acbc3285d61bc9a66cc6017e41de69de5f70d08c5fe37761c8cea80ad6afbf4e63dc9c7f493584d7436b2c05cf7ade0f5352
@@ -0,0 +1 @@
1
+ github: [cedarcode]
@@ -29,16 +29,12 @@ runs:
29
29
  ./Configure --prefix=$HOME/openssl --libdir=lib linux-x86_64
30
30
  make depend && make -j4 && make install_sw
31
31
  ;;
32
- 3.*)
32
+ 3.* | 4.*)
33
33
  OPENSSL_COMMIT=openssl-
34
34
  OPENSSL_COMMIT+=$(echo ${{ inputs.version }})
35
35
  git clone -b $OPENSSL_COMMIT --depth 1 https://github.com/openssl/openssl.git .
36
36
  echo "Git commit: $(git rev-parse HEAD)"
37
- if [[ ${{ inputs.version }} == 3.5* ]]; then
38
- ./Configure --prefix=$HOME/openssl --libdir=lib enable-fips no-tests no-legacy
39
- else
40
- ./Configure --prefix=$HOME/openssl --libdir=lib enable-fips no-tests
41
- fi
37
+ ./Configure --prefix=$HOME/openssl --libdir=lib enable-fips no-tests
42
38
  make -j4 && make install_sw && make install_fips
43
39
  ;;
44
40
  *)
@@ -21,18 +21,30 @@ jobs:
21
21
  fail-fast: false
22
22
  matrix:
23
23
  ruby:
24
+ - '4.0'
24
25
  - '3.4'
25
26
  - '3.3'
26
27
  - '3.2'
27
28
  - '3.1'
28
29
  openssl:
29
- - '3.5.3'
30
- - '3.4.2'
31
- - '3.3.4'
32
- - '3.2.5'
30
+ - '4.0.0'
31
+ - '3.6.0'
32
+ - '3.5.4'
33
+ - '3.4.3'
34
+ - '3.3.5'
35
+ - '3.2.6'
33
36
  - '3.1.8'
34
- - '3.0.17'
37
+ - '3.0.18'
35
38
  - '1.1.1w'
39
+ exclude:
40
+ # Ruby 3.1-3.3 bundle an `openssl` gem too old for OpenSSL 4.0.
41
+ # Re-enable once upstream ships patch releases that bump it.
42
+ - ruby: '3.3'
43
+ openssl: '4.0.0'
44
+ - ruby: '3.2'
45
+ openssl: '4.0.0'
46
+ - ruby: '3.1'
47
+ openssl: '4.0.0'
36
48
  include:
37
49
  - ruby: truffleruby
38
50
  - ruby: '3.0'
@@ -45,7 +57,7 @@ jobs:
45
57
  openssl: '1.1.1w'
46
58
 
47
59
  steps:
48
- - uses: actions/checkout@v5
60
+ - uses: actions/checkout@v7
49
61
 
50
62
  - name: Install OpenSSL
51
63
  if: matrix.ruby != 'truffleruby'
@@ -68,13 +80,11 @@ jobs:
68
80
  bundler-cache: true
69
81
 
70
82
  - run: bundle exec rspec
71
- env:
72
- RUBYOPT: ${{ startsWith(matrix.ruby, '3.4') && '--enable=frozen-string-literal' || '' }}
73
83
 
74
84
  lint:
75
85
  runs-on: ubuntu-latest
76
86
  steps:
77
- - uses: actions/checkout@v5
87
+ - uses: actions/checkout@v7
78
88
  - uses: ruby/setup-ruby@v1
79
89
  with:
80
90
  ruby-version: '3.3'
@@ -14,7 +14,7 @@ jobs:
14
14
  runs-on: ubuntu-latest
15
15
 
16
16
  steps:
17
- - uses: actions/checkout@v5
17
+ - uses: actions/checkout@v7
18
18
  - name: Block autosquash commits
19
19
  uses: xt0rted/block-autosquash-commits-action@v2
20
20
  with:
@@ -23,11 +23,7 @@ jobs:
23
23
  uses: ruby/setup-ruby@v1
24
24
  with:
25
25
  bundler-cache: true
26
- # This release line requires Bundler < 3, and Ruby 4.0 ships with Bundler 4.
27
- ruby-version: "3.4"
28
-
29
- - name: Install openssl
30
- run: gem install openssl --no-document --version 4.0.2
26
+ ruby-version: ruby
31
27
 
32
28
  - name: Publish to RubyGems
33
29
  uses: rubygems/release-gem@v1
data/CHANGELOG.md CHANGED
@@ -1,53 +1,71 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## [Unreleased](https://github.com/cedarcode/webauthn-ruby/compare/v3.4.3...master/)
4
4
 
5
- ## [v3.4.4] - 2026-11-10
5
+ ## [v3.5.0](https://github.com/cedarcode/webauthn-ruby/compare/v3.4.3...v3.5.0/)
6
+
7
+ ### Added
8
+
9
+ - Add support for crossOrigin/topOrigin verification during credential registration and authentication. [#486](https://github.com/cedarcode/webauthn-ruby/pull/486) [@nicolastemciuc]
10
+ - Add support for the `attestation_formats` option in `WebAuthn::Credential.options_for_create`. [#514](https://github.com/cedarcode/webauthn-ruby/pull/514) [@santiagorodriguez96]
11
+ - Add support for the `hints` option in `WebAuthn::Credential.options_for_create` and `WebAuthn::Credential.options_for_get`. [#513](https://github.com/cedarcode/webauthn-ruby/pull/513) [@santiagorodriguez96]
12
+ - Reject authenticator data where the BS (backup state) flag is set but the BE (backup eligibility) flag is not, during credential registration and authentication. Raises `WebAuthn::BackupFlagsVerificationError`. [#516](https://github.com/cedarcode/webauthn-ruby/pull/516) [@santiagorodriguez96]
13
+ - Reject credential IDs longer than 1023 bytes during credential registration. Raises `WebAuthn::CredentialIdLengthVerificationError`. [#517](https://github.com/cedarcode/webauthn-ruby/pull/517) [@santiagorodriguez96]
14
+ - Add `WebAuthn.generate_user_handle` as an alias for `generate_user_id`. [#503](https://github.com/cedarcode/webauthn-ruby/pull/503) [@ttanimichi]
6
15
 
7
16
  ### Changed
8
17
 
9
- - Update `cbor` dependency from `~> 0.5.9` to `~> 0.6.2.2` and `cose` dependency from `~> 1.1` to `~> 1.4`. [#523](https://github.com/cedarcode/webauthn-ruby/pull/523) [@stanhu]
18
+ - Bump the default `credential_options_timeout` from `120_000` to `300_000` milliseconds (5 minutes). [#515](https://github.com/cedarcode/webauthn-ruby/pull/515) [@santiagorodriguez96]
19
+ - `WebAuthn::FakeClient#get` now defaults `backup_state` to `false`. The previous default (`backup_eligibility: false`, `backup_state: true`) produced authenticator data that now fails verification. [#516](https://github.com/cedarcode/webauthn-ruby/pull/516) [@santiagorodriguez96]
20
+ - Avoid mutating caller relying-party options. [#509](https://github.com/cedarcode/webauthn-ruby/pull/509) [@OskarEichler]
10
21
 
11
- ## [v3.4.3] - 2025-10-23
22
+ ### Removed
23
+
24
+ - Remove `TokenBinding` verification during credential registration and authentication. [#450](https://github.com/cedarcode/webauthn-ruby/pull/450) [@nicolastemciuc]
25
+ - BREAKING CHANGE: `WebAuthn::TokenBindingVerificationError` no longer exists. Remove it from any `rescue` clauses.
26
+ - BREAKING CHANGE: `WebAuthn::FakeClient.new` no longer accepts `token_binding:`.
27
+ - BREAKING CHANGE: `WebAuthn::ClientData` no longer exposes `#token_binding` or `#valid_token_binding_format?`.
28
+
29
+ ## [v3.4.3](https://github.com/cedarcode/webauthn-ruby/compare/v3.4.2...v3.4.3/) - 2025-10-23
12
30
 
13
31
  ### Fixed
14
32
 
15
- - Fix `RelyingParty#origin` and `WebAuthn.configuration.origin` always returning `nil`. [#484](https://github.com/cedarcode/webauthn-ruby/pull/484)[@santiagorodriguez96]
33
+ - Fix `RelyingParty#origin` and `WebAuthn.configuration.origin` always returning `nil`. [#484](https://github.com/cedarcode/webauthn-ruby/pull/484) [@santiagorodriguez96]
16
34
  - Now they return the allowed origin if allowed origins has only one element.
17
35
 
18
- ## [v3.4.2] - 2025-09-22
36
+ ## [v3.4.2](https://github.com/cedarcode/webauthn-ruby/compare/v3.4.1...v3.4.2/) - 2025-09-22
19
37
 
20
38
  ### Added
21
39
 
22
40
  - Updated `safety_net_attestation` dependency from `~> 0.4.0` to `~> 0.5.0`.
23
41
 
24
- ## [v3.4.1] - 2025-06-06
42
+ ## [v3.4.1](https://github.com/cedarcode/webauthn-ruby/compare/v3.4.0...v3.4.1/) - 2025-06-06
25
43
 
26
- - Avoid requiring `base64` as it's not a direct dependency. [#459](https://github.com/cedarcode/webauthn-ruby/pull/459)[@santiagorodriguez96]
44
+ - Avoid requiring `base64` as it's not a direct dependency. [#459](https://github.com/cedarcode/webauthn-ruby/pull/459) [@santiagorodriguez96]
27
45
 
28
- ## [v3.4.0] - 2025-02-17
46
+ ## [v3.4.0](https://github.com/cedarcode/webauthn-ruby/compare/v3.3.0...v3.4.0/) - 2025-02-17
29
47
 
30
- - Added support for Webauthn.config and RelayingParty to accept multiple allowed_origins. [#431](https://github.com/cedarcode/webauthn-ruby/pull/431)[@obroshnij]
48
+ - Added support for Webauthn.config and RelayingParty to accept multiple allowed_origins. [#431](https://github.com/cedarcode/webauthn-ruby/pull/431) [@obroshnij]
31
49
 
32
- ## [v3.3.0] - 2025-02-06
50
+ ## [v3.3.0](https://github.com/cedarcode/webauthn-ruby/compare/v3.2.2...v3.3.0/) - 2025-02-06
33
51
 
34
52
  ### Added
35
53
 
36
54
  - Updated `tpm-key_attestation` dependency from `~> 0.12.0` to `~> 0.14.0`. [#449](https://github.com/cedarcode/webauthn-ruby/pull/449) [@brauliomartinezlm], [@nicolastemciuc]
37
55
 
38
- ## [v3.2.2] - 2024-11-14
56
+ ## [v3.2.2](https://github.com/cedarcode/webauthn-ruby/compare/v3.2.1...v3.2.2/) - 2024-11-14
39
57
 
40
58
  ### Fixed
41
59
 
42
60
  - Fix `PublicKeyCredential::Options#.as_json` not camelCase'ing keys of attributes with hash or arrays as values. [#445](https://github.com/cedarcode/webauthn-ruby/pull/445) [@santiagorodriguez96]
43
61
 
44
- ## [v3.2.1] - 2024-11-14
62
+ ## [v3.2.1](https://github.com/cedarcode/webauthn-ruby/compare/v3.2.0...v3.2.1/) - 2024-11-14
45
63
 
46
64
  ### Fixed
47
65
 
48
- - Fix JSON Serializer generating json with attributes with a null value. [#442](https://github.com/cedarcode/webauthn-ruby/pull/442) @santiagorodriguez96
66
+ - Fix JSON Serializer generating json with attributes with a null value. [#442](https://github.com/cedarcode/webauthn-ruby/pull/442) [@santiagorodriguez96]
49
67
 
50
- ## [v3.2.0] - 2024-11-13
68
+ ## [v3.2.0](https://github.com/cedarcode/webauthn-ruby/compare/v3.1.0...v3.2.0/) - 2024-11-13
51
69
 
52
70
  ### Added
53
71
 
@@ -68,31 +86,31 @@
68
86
 
69
87
  - Remove unused class `AttestationTrustworthinessVerificationError`. [#412](https://github.com/cedarcode/webauthn-ruby/pull/412) [@soartec-lab]
70
88
 
71
- ## [v3.1.0] - 2023-12-26
89
+ ## [v3.1.0](https://github.com/cedarcode/webauthn-ruby/compare/v3.0.0...v3.1.0/) - 2023-12-26
72
90
 
73
91
  ### Added
74
92
 
75
- - Add support for optional `authenticator_attachment` in `PublicKeyCredential`. #370 [@8ma10s]
93
+ - Add support for optional `authenticator_attachment` in `PublicKeyCredential`. [#370](https://github.com/cedarcode/webauthn-ruby/pull/370) [@8ma10s]
76
94
 
77
95
  ### Fixed
78
96
 
79
- - Fix circular require warning between `webauthn/relying_party` and `webauthn/credential`. #389 [@bdewater]
80
- - Correctly verify attestation that contains just a batch certificate that is present in the attestation root certificates. #406 [@santiagorodriguez96]
97
+ - Fix circular require warning between `webauthn/relying_party` and `webauthn/credential`. [#389](https://github.com/cedarcode/webauthn-ruby/pull/389) [@bdewater]
98
+ - Correctly verify attestation that contains just a batch certificate that is present in the attestation root certificates. [#406](https://github.com/cedarcode/webauthn-ruby/pull/406) [@santiagorodriguez96]
81
99
 
82
100
  ### Changed
83
101
 
84
- - Inlined `base64` implementation. #402 [@olleolleolle]
85
- - Raise a more descriptive error if input `challenge` is `nil` when verifying the `PublicKeyCredential`. #413 [@soartec-lab]
102
+ - Inlined `base64` implementation. [#402](https://github.com/cedarcode/webauthn-ruby/pull/402) [@olleolleolle]
103
+ - Raise a more descriptive error if input `challenge` is `nil` when verifying the `PublicKeyCredential`. [#413](https://github.com/cedarcode/webauthn-ruby/pull/413) [@soartec-lab]
86
104
 
87
105
  ## [v3.0.0] - 2023-02-15
88
106
 
89
107
  ### Added
90
108
 
91
- - Add the capability of handling appid extension #319 [@santiagorodriguez96]
92
- - Add support for credential backup flags #378 [@santiagorodriguez96]
109
+ - Add the capability of handling appid extension [#319](https://github.com/cedarcode/webauthn-ruby/pull/319) [@santiagorodriguez96]
110
+ - Add support for credential backup flags [#378](https://github.com/cedarcode/webauthn-ruby/pull/378) [@santiagorodriguez96]
93
111
  - Update dependencies to make gem compatible with OpenSSL 3.1 ([@bdewater],[@santiagorodriguez96])
94
112
 
95
- ## [v3.0.0.alpha2] - 2022-09-12
113
+ ## [v3.0.0.alpha2](https://github.com/cedarcode/webauthn-ruby/compare/2-stable...v3.0.0.alpha2/) - 2022-09-12
96
114
 
97
115
  ### Added
98
116
 
@@ -102,19 +120,19 @@
102
120
 
103
121
  - Bumped minimum required Ruby version to 2.5 ([@bdewater])
104
122
 
105
- ## [v3.0.0.alpha1] - 2020-06-27
123
+ ## [v3.0.0.alpha1](https://github.com/cedarcode/webauthn-ruby/compare/v2.3.0...v3.0.0.alpha1) - 2020-06-27
106
124
 
107
125
  ### Added
108
126
 
109
127
  - Ability to define multiple relying parties with the introduction of the `WebAuthn::RelyingParty` class ([@padulafacundo], [@brauliomartinezlm])
110
128
 
111
- ## [v2.5.2] - 2022-07-13
129
+ ## [v2.5.2](https://github.com/cedarcode/webauthn-ruby/compare/v2.5.1...v2.5.2/) - 2022-07-13
112
130
 
113
131
  ### Added
114
132
 
115
133
  - Updated dependencies to make the gem compatible with openssl-3 [@ClearlyClaire]
116
134
 
117
- ## [v2.5.1] - 2022-03-20
135
+ ## [v2.5.1](https://github.com/cedarcode/webauthn-ruby/compare/v2.5.0...v2.5.1/) - 2022-03-20
118
136
 
119
137
  ### Added
120
138
 
@@ -122,9 +140,9 @@
122
140
 
123
141
  ### Removed
124
142
 
125
- - Removed dependency [secure_compare dependency] (https://rubygems.org/gems/secure_compare/versions/0.0.1) and use OpenSSL#secure_compare instead [@bdewater]
143
+ - Removed dependency [secure_compare dependency](https://rubygems.org/gems/secure_compare/versions/0.0.1) and use OpenSSL#secure_compare instead [@bdewater]
126
144
 
127
- ## [v2.5.0] - 2021-03-14
145
+ ## [v2.5.0](https://github.com/cedarcode/webauthn-ruby/compare/v2.4.1...v2.5.0/) - 2021-03-14
128
146
 
129
147
  ### Added
130
148
 
@@ -135,32 +153,32 @@
135
153
 
136
154
  - No longer accept "removed from the WebAuthn spec" options `rp: { icon: }` and `user: { icon: }` for `WebAuthn::Credential.options_for_create` method ([#326](https://github.com/cedarcode/webauthn-ruby/pull/326) / [@santiagorodriguez96])
137
155
 
138
- ## [v2.4.1] - 2021-02-15
156
+ ## [v2.4.1](https://github.com/cedarcode/webauthn-ruby/compare/v2.4.0...v2.4.1/) - 2021-02-15
139
157
 
140
158
  ### Fixed
141
159
 
142
160
  - Fix verification of new credential if no attestation provided and 'None' type is not among configured `acceptable_attestation_types`. I.e. reject it instead of letting it go through.
143
161
 
144
- ## [v2.4.0] - 2020-09-03
162
+ ## [v2.4.0](https://github.com/cedarcode/webauthn-ruby/compare/v2.3.0...v2.4.0/) - 2020-09-03
145
163
 
146
164
  ### Added
147
165
 
148
166
  - Support for ES256K credentials
149
167
  - `FakeClient#get` accepts `user_handle:` keyword argument ([@lgarron])
150
168
 
151
- ## [v2.3.0] - 2020-06-27
169
+ ## [v2.3.0](https://github.com/cedarcode/webauthn-ruby/compare/v2.2.1...v2.3.0/) - 2020-06-27
152
170
 
153
171
  ### Added
154
172
 
155
173
  - Ability to access extension outputs with `PublicKeyCredential#client_extension_outputs` and `PublicKeyCredential#authenticator_extension_outputs` ([@santiagorodriguez96])
156
174
 
157
- ## [v2.2.1] - 2020-06-06
175
+ ## [v2.2.1](https://github.com/cedarcode/webauthn-ruby/compare/v2.2.0...v2.2.1/) - 2020-06-06
158
176
 
159
177
  ### Fixed
160
178
 
161
179
  - Fixed compatibility with OpenSSL-C (libssl) v1.0.2 ([@santiagorodriguez96])
162
180
 
163
- ## [v2.2.0] - 2020-03-14
181
+ ## [v2.2.0](https://github.com/cedarcode/webauthn-ruby/compare/v2.1.0...v2.2.0/) - 2020-03-14
164
182
 
165
183
  ### Added
166
184
 
@@ -169,7 +187,7 @@
169
187
 
170
188
  Note: Expect possible breaking changes for "EXPERIMENTAL" features.
171
189
 
172
- ## [v2.1.0] - 2019-12-30
190
+ ## [v2.1.0](https://github.com/cedarcode/webauthn-ruby/compare/v2.0.0...v2.1.0/) - 2019-12-30
173
191
 
174
192
  ### Added
175
193
 
@@ -181,7 +199,7 @@ Note: Expect possible breaking changes for "EXPERIMENTAL" features.
181
199
 
182
200
  Note: Expect possible breaking changes for "EXPERIMENTAL" features.
183
201
 
184
- ## [v2.0.0] - 2019-10-03
202
+ ## [v2.0.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.18.0...v2.0.0/) - 2019-10-03
185
203
 
186
204
  ### Added
187
205
 
@@ -233,7 +251,7 @@ string keys instead of snake_case symbol keys in the returned hash.
233
251
  - `WebAuthn::FakeClient#create` and `WebAuthn::FakeClient#get` better fakes a real client by not padding the
234
252
  returned base64url-encoded `id` value.
235
253
 
236
- ## [v1.18.0] - 2019-07-27
254
+ ## [v1.18.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.17.0...v1.18.0/) - 2019-07-27
237
255
 
238
256
  ### Added
239
257
 
@@ -248,14 +266,14 @@ returned base64url-encoded `id` value.
248
266
  - Properly verify SafetyNet certificates from input ([#233](https://github.com/cedarcode/webauthn-ruby/pull/233)) ([@bdewater])
249
267
  - FakeClient default origin URL ([#242](https://github.com/cedarcode/webauthn-ruby/pull/242)) ([@kalebtesfay])
250
268
 
251
- ## [v1.17.0] - 2019-06-18
269
+ ## [v1.17.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.16.0...v1.17.0/) - 2019-06-18
252
270
 
253
271
  ### Added
254
272
 
255
273
  - Support ES384, ES512, PS384, PS512, RS384 and RS512 credentials. Off by default. Enable by adding any of them to `WebAuthn.configuration.algorithms` array ([@bdewater])
256
274
  - Support [Signature Counter](https://www.w3.org/TR/webauthn/#signature-counter) verification ([@bdewater])
257
275
 
258
- ## [v1.16.0] - 2019-06-13
276
+ ## [v1.16.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.15.0...v1.16.0/) - 2019-06-13
259
277
 
260
278
  ### Added
261
279
 
@@ -263,20 +281,20 @@ returned base64url-encoded `id` value.
263
281
  - Support RS1 (RSA w/ SHA-1) credentials. Off by default. Enable by adding `"RS1"` to `WebAuthn.configuration.algorithms` array.
264
282
  - Support PS256 (RSA Probabilistic Signature Scheme w/ SHA-256) credentials. On by default ([@bdewater])
265
283
 
266
- ## [v1.15.0] - 2019-05-16
284
+ ## [v1.15.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.14.0...v1.15.0/) - 2019-05-16
267
285
 
268
286
  ### Added
269
287
 
270
288
  - Ability to configure Origin, RP ID and RP Name via `WebAuthn.configure`
271
289
 
272
- ## [v1.14.0] - 2019-04-25
290
+ ## [v1.14.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.13.0...v1.14.0/) - 2019-04-25
273
291
 
274
292
  ### Added
275
293
 
276
294
  - Support 'tpm' attestation statement
277
295
  - Support RS256 credential public key
278
296
 
279
- ## [v1.13.0] - 2019-04-09
297
+ ## [v1.13.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.12.0...v1.13.0/) - 2019-04-09
280
298
 
281
299
  ### Added
282
300
 
@@ -289,7 +307,7 @@ returned base64url-encoded `id` value.
289
307
  - Verify collectedClientData.tokenBinding format.
290
308
  - `WebAuthn.credential_creation_options` now accept `rp_name`, `user_id`, `user_name` and `display_name` as keyword arguments ([@bdewater])
291
309
 
292
- ## [v1.12.0] - 2019-04-03
310
+ ## [v1.12.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.11.0...v1.12.0/) - 2019-04-03
293
311
 
294
312
  ### Added
295
313
 
@@ -305,7 +323,7 @@ Note #1: A `Credential` instance is what is returned in `WebAuthn::Authenticator
305
323
  Note #2: You don't need to do any convesion before passing the public key in `AuthenticatorAssertionResponse#verify`'s
306
324
  `allowed_credentials` argument, `#verify` is backwards-compatible and will handle both public key formats properly.
307
325
 
308
- ## [v1.11.0] - 2019-03-15
326
+ ## [v1.11.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.10.0...v1.11.0/) - 2019-03-15
309
327
 
310
328
  ### Added
311
329
 
@@ -315,19 +333,19 @@ Note #2: You don't need to do any convesion before passing the public key in `Au
315
333
 
316
334
  - Verify matching AAGUID if needed when verifying `packed` attestation statements ([@bdewater])
317
335
 
318
- ## [v1.10.0] - 2019-03-05
336
+ ## [v1.10.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.9.0...v1.10.0/) - 2019-03-05
319
337
 
320
338
  ### Added
321
339
 
322
340
  - Parse and make AuthenticatorData's extensionData available
323
341
 
324
- ## [v1.9.0] - 2019-02-22
342
+ ## [v1.9.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.8.0...v1.9.0/) - 2019-02-22
325
343
 
326
344
  ### Added
327
345
 
328
346
  - Added `#verify`, which can be used for getting a meaningful error raised in case of a verification error, as opposed to `#valid?` which returns `false`
329
347
 
330
- ## [v1.8.0] - 2019-01-17
348
+ ## [v1.8.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.7.0...v1.8.0/) - 2019-01-17
331
349
 
332
350
  ### Added
333
351
 
@@ -338,40 +356,40 @@ Note #2: You don't need to do any convesion before passing the public key in `Au
338
356
 
339
357
  - Make current raised exception errors a bit more meaningful to aid debugging
340
358
 
341
- ## [v1.7.0] - 2018-11-08
359
+ ## [v1.7.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.6.0...v1.7.0/) - 2018-11-08
342
360
 
343
361
  ### Added
344
362
 
345
363
  - _Registration_ ceremony
346
364
  - `WebAuthn::AuthenticatorAttestationResponse` exposes attestation type and trust path via `#attestation_type` and `#attestation_trust_path` methods ([@bdewater])
347
365
 
348
- ## [v1.6.0] - 2018-11-01
366
+ ## [v1.6.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.5.0...v1.6.0/) - 2018-11-01
349
367
 
350
368
  ### Added
351
369
 
352
370
  - `FakeAuthenticator` object is now exposed to help you test your WebAuthn implementation
353
371
 
354
- ## [v1.5.0] - 2018-10-23
372
+ ## [v1.5.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.4.0...v1.5.0/) - 2018-10-23
355
373
 
356
374
  ### Added
357
375
 
358
376
  - Works with ruby 2.3 ([@bdewater])
359
377
 
360
- ## [v1.4.0] - 2018-10-11
378
+ ## [v1.4.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.3.0...v1.4.0/) - 2018-10-11
361
379
 
362
380
  ### Added
363
381
 
364
382
  - _Registration_ ceremony
365
383
  - `WebAuthn::AuthenticatorAttestationResponse.valid?` supports `android-safetynet` attestation statements ([@bdewater])
366
384
 
367
- ## [v1.3.0] - 2018-10-11
385
+ ## [v1.3.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.2.0...v1.3.0/) - 2018-10-11
368
386
 
369
387
  ### Added
370
388
 
371
389
  - _Registration_ ceremony
372
390
  - `WebAuthn::AuthenticatorAttestationResponse.valid?` supports `packed` attestation statements ([@sorah])
373
391
 
374
- ## [v1.2.0] - 2018-10-08
392
+ ## [v1.2.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.1.0...v1.2.0/) - 2018-10-08
375
393
 
376
394
  ### Added
377
395
 
@@ -382,7 +400,7 @@ Note #2: You don't need to do any convesion before passing the public key in `Au
382
400
 
383
401
  Note: Both additions should help making it compatible with Chrome for Android 70+/Android Fingerprint pair.
384
402
 
385
- ## [v1.1.0] - 2018-10-04
403
+ ## [v1.1.0](https://github.com/cedarcode/webauthn-ruby/compare/v1.0.0...v1.1.0/) - 2018-10-04
386
404
 
387
405
  ### Added
388
406
 
@@ -391,7 +409,7 @@ Note: Both additions should help making it compatible with Chrome for Android 70
391
409
  - _Authentication_ ceremony
392
410
  - `WebAuthn::AuthenticatorAssertionResponse.valid?` optionally accepts rp_id.
393
411
 
394
- ## [v1.0.0] - 2018-09-07
412
+ ## [v1.0.0](https://github.com/cedarcode/webauthn-ruby/compare/v0.2.0...v1.0.0/) - 2018-09-07
395
413
 
396
414
  ### Added
397
415
 
@@ -405,7 +423,7 @@ Note: Both additions should help making it compatible with Chrome for Android 70
405
423
  - _Authentication_ ceremony
406
424
  - Use 32-byte challenge instead of 16-byte
407
425
 
408
- ## [v0.2.0] - 2018-06-08
426
+ ## [v0.2.0](https://github.com/cedarcode/webauthn-ruby/compare/v0.1.0...v0.2.0/) - 2018-06-08
409
427
 
410
428
  ### Added
411
429
 
@@ -433,7 +451,7 @@ Note: Both additions should help making it compatible with Chrome for Android 70
433
451
  - _Registration_ ceremony
434
452
  - `WebAuthn::AuthenticatorAttestationResponse.credential_id` (superseded by `WebAuthn::AuthenticatorAttestationResponse.credential`)
435
453
 
436
- ## [v0.1.0] - 2018-05-25
454
+ ## [v0.1.0](https://github.com/cedarcode/webauthn-ruby/compare/v0.0.0...v0.1.0/) - 2018-05-25
437
455
 
438
456
  ### Added
439
457
 
@@ -442,63 +460,25 @@ Note: Both additions should help making it compatible with Chrome for Android 70
442
460
  - `WebAuthn::AuthenticatorAttestationResponse.valid?` can be used to validate fido-u2f attestations returned by the browser
443
461
  - Works with ruby 2.5
444
462
 
445
- [v3.4.4]: https://github.com/cedarcode/webauthn-ruby/compare/v3.4.3...v3.4.4/
446
- [v3.4.2]: https://github.com/cedarcode/webauthn-ruby/compare/v3.4.1...v3.4.2/
447
- [v3.4.1]: https://github.com/cedarcode/webauthn-ruby/compare/v3.4.0...v3.4.1/
448
- [v3.4.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.3.0...v3.4.0/
449
- [v3.3.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.2.2...v3.3.0/
450
- [v3.2.2]: https://github.com/cedarcode/webauthn-ruby/compare/v3.2.1...v3.2.2/
451
- [v3.2.1]: https://github.com/cedarcode/webauthn-ruby/compare/v3.2.0...v3.2.1/
452
- [v3.2.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.1.0...v3.2.0/
453
- [v3.1.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.0.0...v3.1.0/
454
- [v3.0.0]: https://github.com/cedarcode/webauthn-ruby/compare/2-stable...v3.0.0/
455
- [v3.0.0.alpha2]: https://github.com/cedarcode/webauthn-ruby/compare/2-stable...v3.0.0.alpha2/
456
- [v3.0.0.alpha1]: https://github.com/cedarcode/webauthn-ruby/compare/v2.3.0...v3.0.0.alpha1
457
- [v2.5.2]: https://github.com/cedarcode/webauthn-ruby/compare/v2.5.1...v2.5.2/
458
- [v2.5.1]: https://github.com/cedarcode/webauthn-ruby/compare/v2.5.0...v2.5.1/
459
- [v2.5.0]: https://github.com/cedarcode/webauthn-ruby/compare/v2.4.1...v2.5.0/
460
- [v2.4.1]: https://github.com/cedarcode/webauthn-ruby/compare/v2.4.0...v2.4.1/
461
- [v2.4.0]: https://github.com/cedarcode/webauthn-ruby/compare/v2.3.0...v2.4.0/
462
- [v2.3.0]: https://github.com/cedarcode/webauthn-ruby/compare/v2.2.1...v2.3.0/
463
- [v2.2.1]: https://github.com/cedarcode/webauthn-ruby/compare/v2.2.0...v2.2.1/
464
- [v2.2.0]: https://github.com/cedarcode/webauthn-ruby/compare/v2.1.0...v2.2.0/
465
- [v2.1.0]: https://github.com/cedarcode/webauthn-ruby/compare/v2.0.0...v2.1.0/
466
- [v2.0.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.18.0...v2.0.0/
467
- [v1.18.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.17.0...v1.18.0/
468
- [v1.17.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.16.0...v1.17.0/
469
- [v1.16.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.15.0...v1.16.0/
470
- [v1.15.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.14.0...v1.15.0/
471
- [v1.14.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.13.0...v1.14.0/
472
- [v1.13.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.12.0...v1.13.0/
473
- [v1.12.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.11.0...v1.12.0/
474
- [v1.11.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.10.0...v1.11.0/
475
- [v1.10.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.9.0...v1.10.0/
476
- [v1.9.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.8.0...v1.9.0/
477
- [v1.8.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.7.0...v1.8.0/
478
- [v1.7.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.6.0...v1.7.0/
479
- [v1.6.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.5.0...v1.6.0/
480
- [v1.5.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.4.0...v1.5.0/
481
- [v1.4.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.3.0...v1.4.0/
482
- [v1.3.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.2.0...v1.3.0/
483
- [v1.2.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.1.0...v1.2.0/
484
- [v1.1.0]: https://github.com/cedarcode/webauthn-ruby/compare/v1.0.0...v1.1.0/
485
- [v1.0.0]: https://github.com/cedarcode/webauthn-ruby/compare/v0.2.0...v1.0.0/
486
- [v0.2.0]: https://github.com/cedarcode/webauthn-ruby/compare/v0.1.0...v0.2.0/
487
- [v0.1.0]: https://github.com/cedarcode/webauthn-ruby/compare/v0.0.0...v0.1.0/
488
-
489
- [@brauliomartinezlm]: https://github.com/brauliomartinezlm
490
463
  [@bdewater]: https://github.com/bdewater
464
+ [@brauliomartinezlm]: https://github.com/brauliomartinezlm
465
+ [@ClearlyClaire]: https://github.com/ClearlyClaire
491
466
  [@jdongelmans]: https://github.com/jdongelmans
467
+ [@jdongelmans]: https://github.com/jdongelmans
468
+ [@juanarias93]: https://github.com/juanarias93
492
469
  [@kalebtesfay]: https://github.com/kalebtesfay
470
+ [@kingjan1999]: https://github.com/@kingjan1999
471
+ [@lgarron]: https://github.com/lgarron
493
472
  [@MaximeNdutiye]: https://github.com/MaximeNdutiye
494
- [@sorah]: https://github.com/sorah
495
- [@ssuttner]: https://github.com/ssuttner
496
- [@stanhu]: https://github.com/stanhu
473
+ [@nicolastemciuc]: https://github.com/nicolastemciuc
474
+ [@obroshnij]: https://github.com/obroshnij
475
+ [@olleolleolle]: https://github.com/olleolleolle
476
+ [@OskarEichler]: https://github.com/OskarEichler
497
477
  [@padulafacundo]: https://github.com/padulafacundo
498
- [@santiagorodriguez96]: https://github.com/santiagorodriguez96
499
- [@lgarron]: https://github.com/lgarron
500
- [@juanarias93]: https://github.com/juanarias93
501
- [@kingjan1999]: https://github.com/@kingjan1999
502
- [@jdongelmans]: https://github.com/jdongelmans
503
478
  [@petergoldstein]: https://github.com/petergoldstein
504
- [@ClearlyClaire]: https://github.com/ClearlyClaire
479
+ [@santiagorodriguez96]: https://github.com/santiagorodriguez96
480
+ [@soartec-lab]: https://github.com/soartec-lab
481
+ [@sorah]: https://github.com/sorah
482
+ [@ssuttner]: https://github.com/ssuttner
483
+ [@ttanimichi]: https://github.com/ttanimichi
484
+ [@8ma10s]: https://github.com/8ma10s
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.4"
4
+ VERSION = "3.5.0"
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.6.2.2"
39
- spec.add_dependency "cose", "~> 1.4"
38
+ spec.add_dependency "cbor", "~> 0.5.9"
39
+ spec.add_dependency "cose", "~> 1.1"
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"
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: 3.4.4
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Rodriguez
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.6.2.2
47
+ version: 0.5.9
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.6.2.2
54
+ version: 0.5.9
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cose
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.4'
61
+ version: '1.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.4'
68
+ version: '1.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: openssl
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '1.17'
118
118
  - - "<"
119
119
  - !ruby/object:Gem::Version
120
- version: '3.0'
120
+ version: '5.0'
121
121
  type: :development
122
122
  prerelease: false
123
123
  version_requirements: !ruby/object:Gem::Requirement
@@ -127,7 +127,7 @@ dependencies:
127
127
  version: '1.17'
128
128
  - - "<"
129
129
  - !ruby/object:Gem::Version
130
- version: '3.0'
130
+ version: '5.0'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: byebug
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +220,7 @@ dependencies:
220
220
  version: '4.0'
221
221
  description: |-
222
222
  WebAuthn ruby server library ― Make your application a W3C Web Authentication conformant
223
- Relying Party and allow your users to authenticate with U2F and FIDO2 authenticators.
223
+ Relying Party and allow your users to authenticate with FIDO2/U2F authenticators as passkeys or security keys.
224
224
  email:
225
225
  - gonzalo@cedarcode.com
226
226
  - braulio@cedarcode.com
@@ -228,6 +228,7 @@ executables: []
228
228
  extensions: []
229
229
  extra_rdoc_files: []
230
230
  files:
231
+ - ".github/FUNDING.yml"
231
232
  - ".github/actions/install-openssl/action.yml"
232
233
  - ".github/actions/install-ruby/action.yml"
233
234
  - ".github/dependabot.yml"
@@ -318,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
319
  - !ruby/object:Gem::Version
319
320
  version: '0'
320
321
  requirements: []
321
- rubygems_version: 3.6.9
322
+ rubygems_version: 4.0.20
322
323
  specification_version: 4
323
324
  summary: WebAuthn ruby server library
324
325
  test_files: []