File tree Expand file tree Collapse file tree 6 files changed +62
-6
lines changed
Expand file tree Collapse file tree 6 files changed +62
-6
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33module WebAuthn
4- VERSION = "3.4.2 "
4+ VERSION = "3.4.3 "
55end
Original file line number Diff line number Diff line change 22
33source "https://rubygems.org"
44
5- ruby "~> 3.4.2"
5+ ruby file : '.ruby-version'
66
77gem "byebug"
88gem "fido_metadata" , "~> 0.5.0"
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 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 (
You can’t perform that action at this time.
0 commit comments