Skip to content

Commit 397e6ed

Browse files
Merge remote-tracking branch 'origin/master' into temciuc--verify-top-origin
2 parents 0f0e324 + bc1d035 commit 397e6ed

File tree

6 files changed

+62
-6
lines changed

6 files changed

+62
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
## [v3.4.3] - 2025-10-23
6+
7+
### Fixed
8+
9+
- Fix `RelyingParty#origin` and `WebAuthn.configuration.origin` always returning `nil`. [#484](https://github.com/cedarcode/webauthn-ruby/pull/484)[@santiagorodriguez96]
10+
- Now they return the allowed origin if allowed origins has only one element.
11+
312
## [v3.4.2] - 2025-09-22
413

514
### Added

lib/webauthn/relying_party.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def initialize(
6060
:acceptable_attestation_types,
6161
:legacy_u2f_appid
6262

63-
attr_reader :attestation_root_certificates_finders, :origin
63+
attr_reader :attestation_root_certificates_finders
6464

6565
# This is the user-data encoder.
6666
# Used to decode user input and to encode data provided to the user.
@@ -127,13 +127,24 @@ def verify_authentication(
127127
end
128128
end
129129

130+
# DEPRECATED: This method will be removed in future.
131+
def origin
132+
warn(
133+
"DEPRECATION WARNING: `WebAuthn.origin` is deprecated and returns `nil` " \
134+
"when `WebAuthn.allowed_origins` contains more than one origin. " \
135+
"It will be removed in future. Please use `WebAuthn.allowed_origins` instead."
136+
)
137+
138+
allowed_origins.first if allowed_origins&.size == 1
139+
end
140+
130141
# DEPRECATED: This method will be removed in future.
131142
def origin=(new_origin)
132143
return if new_origin.nil?
133144

134145
warn(
135-
"DEPRECATION WARNING: `WebAuthn.origin` is deprecated and will be removed in future. "\
136-
"Please use `WebAuthn.allowed_origins` instead "\
146+
"DEPRECATION WARNING: `WebAuthn.origin=` is deprecated and will be removed in future. "\
147+
"Please use `WebAuthn.allowed_origins=` instead "\
137148
"that also allows configuring multiple origins per Relying Party"
138149
)
139150

lib/webauthn/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module WebAuthn
4-
VERSION = "3.4.2"
4+
VERSION = "3.4.3"
55
end

spec/conformance/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
ruby "~> 3.4.2"
5+
ruby file: '.ruby-version'
66

77
gem "byebug"
88
gem "fido_metadata", "~> 0.5.0"

spec/conformance/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ GEM
3131
mustermann (3.0.4)
3232
ruby2_keywords (~> 0.0.1)
3333
nio4r (2.7.4)
34-
openssl (3.3.0)
34+
openssl (3.3.1)
3535
openssl-signature_algorithm (1.3.0)
3636
openssl (> 2.0)
3737
puma (6.6.1)

spec/webauthn/relying_party_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,42 @@
135135
end
136136
end
137137

138+
describe '#origin' do
139+
subject do
140+
old_verbose, $VERBOSE = $VERBOSE, nil # Silence warnings to avoid deprecation warnings
141+
142+
rp.origin
143+
ensure
144+
$VERBOSE = old_verbose
145+
end
146+
147+
context 'when relying party has only one allowed origin' do
148+
let(:rp) do
149+
WebAuthn::RelyingParty.new(allowed_origins: ["https://admin.example.test"])
150+
end
151+
152+
it 'returns that allowed origin' do
153+
is_expected.to eq("https://admin.example.test")
154+
end
155+
end
156+
157+
context 'when relying party has multiple allowed origins' do
158+
let(:rp) do
159+
WebAuthn::RelyingParty.new(allowed_origins: ["https://admin.example.test", "https://newadmin.example.test"])
160+
end
161+
162+
it { is_expected.to be_nil }
163+
end
164+
165+
context 'when relying party has not set its allowed origins' do
166+
let(:rp) do
167+
WebAuthn::RelyingParty.new(allowed_origins: nil)
168+
end
169+
170+
it { is_expected.to be_nil }
171+
end
172+
end
173+
138174
context "without having any global configuration" do
139175
let(:consumer_rp) do
140176
WebAuthn::RelyingParty.new(

0 commit comments

Comments
 (0)