webauthn 3.2.2 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 410e18172c68e2171f46e15d7b34cd56ef7859c4efd421b6a84a3469f0281c41
4
- data.tar.gz: 16841587928fb284c5ad542868a0d6a21f6152a82bdd76abc0ae537887275bc3
3
+ metadata.gz: 325d58807c73a2887233d3b68091bea56edcb9be7fb21f57067d1f974006d876
4
+ data.tar.gz: 24a7b26717f6ab10286f14410db64909a21a4e43cea30b1b168f32caa80412c6
5
5
  SHA512:
6
- metadata.gz: b7337230a3b9118e55bfd1ac84858d163bc173d70107e5f425077579801c5d1b68cf6ec0be65d0317c63d69d1594d7a50662a42e3ed4ac34e45cae97954a8477
7
- data.tar.gz: 53dcf09f8065ee447633de769c5d4587e39150f117fa3f6226a78fbbac7b48be9195bcd40ff14a683f06343a2f10f46c3df057dedaf96fcabfedb41865b64362
6
+ metadata.gz: f12ef1fad4fcf414b7081f9b89a4db5536d301b2c015449a3d2d631ea09a2a087cb6c02f3699f61528f9e9b61d3bf039c37bf0b0885991a7d7e26ac3dadd452a
7
+ data.tar.gz: f6464aaa94ddeec4ddefecb6b94b5fa310ada53d67bd1bf9b146c942dbd29e637790c6ae081d3d4cc81aed12be4a9073f056e2770ab2b846278d07923d67f6bf
@@ -15,12 +15,12 @@ on:
15
15
 
16
16
  jobs:
17
17
  test:
18
- runs-on: ubuntu-20.04
18
+ runs-on: ubuntu-24.04
19
19
  strategy:
20
20
  fail-fast: false
21
21
  matrix:
22
22
  ruby:
23
- - '3.4.0-preview2'
23
+ - '3.4'
24
24
  - '3.3'
25
25
  - '3.2'
26
26
  - '3.1'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.4.0] - 2025-02-17
4
+
5
+ - Added support for Webauthn.config and RelayingParty to accept multiple allowed_origins. [#431](https://github.com/cedarcode/webauthn-ruby/pull/431)[@obroshnij]
6
+
7
+ ## [v3.3.0] - 2025-02-06
8
+
9
+ ### Added
10
+
11
+ - Updated `tpm-key_attestation` dependency from `~> 0.12.0` to `~> 0.14.0`. [#449](https://github.com/cedarcode/webauthn-ruby/pull/449) [@brauliomartinezlm], [@nicolastemciuc]
12
+
3
13
  ## [v3.2.2] - 2024-11-14
4
14
 
5
15
  ### Fixed
@@ -407,6 +417,11 @@ Note: Both additions should help making it compatible with Chrome for Android 70
407
417
  - `WebAuthn::AuthenticatorAttestationResponse.valid?` can be used to validate fido-u2f attestations returned by the browser
408
418
  - Works with ruby 2.5
409
419
 
420
+ [v3.4.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.3.0...v3.4.0/
421
+ [v3.3.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.2.2...v3.3.0/
422
+ [v3.2.2]: https://github.com/cedarcode/webauthn-ruby/compare/v3.2.1...v3.2.2/
423
+ [v3.2.1]: https://github.com/cedarcode/webauthn-ruby/compare/v3.2.0...v3.2.1/
424
+ [v3.2.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.1.0...v3.2.0/
410
425
  [v3.1.0]: https://github.com/cedarcode/webauthn-ruby/compare/v3.0.0...v3.1.0/
411
426
  [v3.0.0]: https://github.com/cedarcode/webauthn-ruby/compare/2-stable...v3.0.0/
412
427
  [v3.0.0.alpha2]: https://github.com/cedarcode/webauthn-ruby/compare/2-stable...v3.0.0.alpha2/
data/README.md CHANGED
@@ -104,7 +104,8 @@ For a Rails application this would go in `config/initializers/webauthn.rb`.
104
104
  WebAuthn.configure do |config|
105
105
  # This value needs to match `window.location.origin` evaluated by
106
106
  # the User Agent during registration and authentication ceremonies.
107
- config.origin = "https://auth.example.com"
107
+ # 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.
108
+ config.allowed_origins = ["https://auth.example.com"]
108
109
 
109
110
  # Relying Party name for display purposes
110
111
  config.rp_name = "Example Inc."
@@ -25,7 +25,8 @@ module WebAuthn
25
25
  end
26
26
 
27
27
  def verify(expected_challenge, expected_origin = nil, user_presence: nil, user_verification: nil, rp_id: nil)
28
- expected_origin ||= relying_party.origin || raise("Unspecified expected origin")
28
+ expected_origin ||= relying_party.allowed_origins || raise("Unspecified expected origin")
29
+
29
30
  rp_id ||= relying_party.id
30
31
 
31
32
  verify_item(:type)
@@ -33,7 +34,11 @@ module WebAuthn
33
34
  verify_item(:challenge, expected_challenge)
34
35
  verify_item(:origin, expected_origin)
35
36
  verify_item(:authenticator_data)
36
- verify_item(:rp_id, rp_id || rp_id_from_origin(expected_origin))
37
+
38
+ verify_item(
39
+ :rp_id,
40
+ rp_id || rp_id_from_origin(expected_origin)
41
+ )
37
42
 
38
43
  # Fallback to RP configuration unless user_presence is passed in explicitely
39
44
  if user_presence.nil? && !relying_party.silent_authentication || user_presence
@@ -84,10 +89,14 @@ module WebAuthn
84
89
  end
85
90
 
86
91
  def valid_origin?(expected_origin)
87
- expected_origin && (client_data.origin == expected_origin)
92
+ return false unless expected_origin
93
+
94
+ expected_origin.include?(client_data.origin)
88
95
  end
89
96
 
90
97
  def valid_rp_id?(rp_id)
98
+ return false unless rp_id
99
+
91
100
  OpenSSL::Digest::SHA256.digest(rp_id) == authenticator_data.rp_id_hash
92
101
  end
93
102
 
@@ -106,7 +115,7 @@ module WebAuthn
106
115
  end
107
116
 
108
117
  def rp_id_from_origin(expected_origin)
109
- URI.parse(expected_origin).host
118
+ URI.parse(expected_origin.first).host if expected_origin.size == 1
110
119
  end
111
120
 
112
121
  def type
@@ -49,12 +49,10 @@ module WebAuthn
49
49
 
50
50
  def data
51
51
  @data ||=
52
- begin
53
- if client_data_json
54
- JSON.parse(client_data_json)
55
- else
56
- raise ClientDataMissingError, "Client Data JSON is missing"
57
- end
52
+ if client_data_json
53
+ JSON.parse(client_data_json)
54
+ else
55
+ raise ClientDataMissingError, "Client Data JSON is missing"
58
56
  end
59
57
  end
60
58
  end
@@ -22,6 +22,8 @@ module WebAuthn
22
22
  :encoding=,
23
23
  :origin,
24
24
  :origin=,
25
+ :allowed_origins,
26
+ :allowed_origins=,
25
27
  :verify_attestation_statement,
26
28
  :verify_attestation_statement=,
27
29
  :credential_options_timeout,
@@ -9,15 +9,16 @@ module WebAuthn
9
9
  class RootCertificateFinderNotSupportedError < Error; end
10
10
 
11
11
  class RelyingParty
12
+ DEFAULT_ALGORITHMS = ["ES256", "PS256", "RS256"].compact.freeze
13
+
12
14
  def self.if_pss_supported(algorithm)
13
15
  OpenSSL::PKey::RSA.instance_methods.include?(:verify_pss) ? algorithm : nil
14
16
  end
15
17
 
16
- DEFAULT_ALGORITHMS = ["ES256", "PS256", "RS256"].compact.freeze
17
-
18
18
  def initialize(
19
19
  algorithms: DEFAULT_ALGORITHMS.dup,
20
20
  encoding: WebAuthn::Encoder::STANDARD_ENCODING,
21
+ allowed_origins: nil,
21
22
  origin: nil,
22
23
  id: nil,
23
24
  name: nil,
@@ -30,7 +31,7 @@ module WebAuthn
30
31
  )
31
32
  @algorithms = algorithms
32
33
  @encoding = encoding
33
- @origin = origin
34
+ @allowed_origins = allowed_origins
34
35
  @id = id
35
36
  @name = name
36
37
  @verify_attestation_statement = verify_attestation_statement
@@ -38,12 +39,13 @@ module WebAuthn
38
39
  @silent_authentication = silent_authentication
39
40
  @acceptable_attestation_types = acceptable_attestation_types
40
41
  @legacy_u2f_appid = legacy_u2f_appid
42
+ self.origin = origin
41
43
  self.attestation_root_certificates_finders = attestation_root_certificates_finders
42
44
  end
43
45
 
44
46
  attr_accessor :algorithms,
45
47
  :encoding,
46
- :origin,
48
+ :allowed_origins,
47
49
  :id,
48
50
  :name,
49
51
  :verify_attestation_statement,
@@ -52,7 +54,7 @@ module WebAuthn
52
54
  :acceptable_attestation_types,
53
55
  :legacy_u2f_appid
54
56
 
55
- attr_reader :attestation_root_certificates_finders
57
+ attr_reader :attestation_root_certificates_finders, :origin
56
58
 
57
59
  # This is the user-data encoder.
58
60
  # Used to decode user input and to encode data provided to the user.
@@ -118,5 +120,18 @@ module WebAuthn
118
120
  block_given? ? [webauthn_credential, stored_credential] : webauthn_credential
119
121
  end
120
122
  end
123
+
124
+ # DEPRECATED: This method will be removed in future.
125
+ def origin=(new_origin)
126
+ return if new_origin.nil?
127
+
128
+ warn(
129
+ "DEPRECATION WARNING: `WebAuthn.origin` is deprecated and will be removed in future. "\
130
+ "Please use `WebAuthn.allowed_origins` instead "\
131
+ "that also allows configuring multiple origins per Relying Party"
132
+ )
133
+
134
+ @allowed_origins ||= Array(new_origin) # rubocop:disable Naming/MemoizedInstanceVariableName
135
+ end
121
136
  end
122
137
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebAuthn
4
- VERSION = "3.2.2"
4
+ VERSION = "3.4.0"
5
5
  end
data/webauthn.gemspec CHANGED
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_dependency "cose", "~> 1.1"
40
40
  spec.add_dependency "openssl", ">= 2.2"
41
41
  spec.add_dependency "safety_net_attestation", "~> 0.4.0"
42
- spec.add_dependency "tpm-key_attestation", "~> 0.12.0"
42
+ spec.add_dependency "tpm-key_attestation", "~> 0.14.0"
43
43
 
44
44
  spec.add_development_dependency "base64", ">= 0.1.0"
45
45
  spec.add_development_dependency "bundler", ">= 1.17", "< 3.0"
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.2.2
4
+ version: 3.4.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: 2024-11-14 00:00:00.000000000 Z
12
+ date: 2025-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: android_key_attestation
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.12.0
104
+ version: 0.14.0
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 0.12.0
111
+ version: 0.14.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: base64
114
114
  requirement: !ruby/object:Gem::Requirement