Skip to content

Commit 026cff1

Browse files
authored
Merge pull request #250 from 55728/webfinger-returns-issuer-location
Webfinger now returns issuer location
2 parents 3129299 + 2d76692 commit 026cff1

4 files changed

Lines changed: 23 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Please add here
44
- [#241] Fix NameError on doorkeeper master by deferring AR model loading in run_hooks (see [Doorkeeper PR](https://github.com/doorkeeper-gem/doorkeeper/pull/1804))
55
- [#246] Fix `at_hash` to use correct hash algorithm based on `signing_algorithm`
6+
* [#250] Return configured `issuer` instead of `root_url` in WebFinger response (thanks to @sato11 for the original work in #172)
67

78
## v1.9.0 (2026-03-16)
89

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ The following settings are optional:
177177
- `discovery_url_options`
178178
- The URL options for every available endpoint to use when generating the endpoint URL in the
179179
discovery response. Available endpoints: `authorization`, `token`, `revocation`,
180-
`introspection`, `userinfo`, `jwks`, `webfinger`.
180+
`introspection`, `userinfo`, `jwks`.
181181
- This option requires option keys with an available endpoint and
182182
[URL options](https://api.rubyonrails.org/v6.0.3.3/classes/ActionDispatch/Routing/UrlFor.html#method-i-url_for)
183183
as value.

app/controllers/doorkeeper/openid_connect/discovery_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def webfinger_response
9696
links: [
9797
{
9898
rel: WEBFINGER_RELATION,
99-
href: root_url(webfinger_url_options),
99+
href: issuer,
100100
}
101101
]
102102
}
@@ -133,7 +133,7 @@ def issuer
133133
Doorkeeper::OpenidConnect.resolve_issuer(request: request)
134134
end
135135

136-
%i[authorization token revocation introspection userinfo jwks webfinger dynamic_client_registration].each do |endpoint|
136+
%i[authorization token revocation introspection userinfo jwks dynamic_client_registration].each do |endpoint|
137137
define_method :"#{endpoint}_url_options" do
138138
discovery_url_default_options.merge(discovery_url_options[endpoint.to_sym] || {})
139139
end

spec/controllers/discovery_controller_spec.rb

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@
219219
end
220220
end
221221

222+
context 'when the issuer is configured to a non-root URL' do
223+
let(:non_root_issuer) { 'http://test.host/issuer/with/path' }
224+
225+
before do
226+
value = non_root_issuer
227+
Doorkeeper::OpenidConnect.configure do
228+
issuer value
229+
end
230+
end
231+
232+
it 'returns the configured issuer in the webfinger response' do
233+
get :webfinger, params: { resource: 'user@example.com' }
234+
data = JSON.parse(response.body)
235+
236+
expect(data['links'].first['href']).to eq non_root_issuer
237+
end
238+
end
239+
222240
context 'when client_credentials is configured with both from_basic and from_params' do
223241
before { Doorkeeper.configure { client_credentials :from_basic, :from_params } }
224242

@@ -366,28 +384,11 @@ def controller.logout_url
366384
'subject' => 'user@example.com',
367385
'links' => [
368386
'rel' => 'http://openid.net/specs/connect/1.0/issuer',
369-
'href' => 'http://test.host/',
387+
'href' => 'dummy',
370388
],
371389
}.sort)
372390
end
373391

374-
context 'when the discovery_url_options option is set for webfinger endpoint' do
375-
before do
376-
Doorkeeper::OpenidConnect.configure do
377-
discovery_url_options do |request|
378-
{ webfinger: { host: 'alternate-webfinger.host' } }
379-
end
380-
end
381-
end
382-
383-
it 'uses the discovery_url_options option when generating the webfinger endpoint url' do
384-
get :webfinger, params: { resource: 'user@example.com' }
385-
data = JSON.parse(response.body)
386-
387-
expect(data['links'].first['href']).to eq 'http://alternate-webfinger.host/'
388-
end
389-
end
390-
391392
context 'when the discovery_url_options option uses the request for an endpoint' do
392393
before do
393394
Doorkeeper::OpenidConnect.configure do

0 commit comments

Comments
 (0)