Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ The following settings are optional:
- `discovery_url_options`
- The URL options for every available endpoint to use when generating the endpoint URL in the
discovery response. Available endpoints: `authorization`, `token`, `revocation`,
`introspection`, `userinfo`, `jwks`, `webfinger`.
`introspection`, `userinfo`, `jwks`.
- This option requires option keys with an available endpoint and
[URL options](https://api.rubyonrails.org/v6.0.3.3/classes/ActionDispatch/Routing/UrlFor.html#method-i-url_for)
as value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def webfinger_response
links: [
{
rel: WEBFINGER_RELATION,
href: root_url(webfinger_url_options),
href: issuer,
}
]
}
Expand Down Expand Up @@ -128,7 +128,7 @@ def issuer
end
end

%i[authorization token revocation introspection userinfo jwks webfinger].each do |endpoint|
%i[authorization token revocation introspection userinfo jwks].each do |endpoint|
define_method :"#{endpoint}_url_options" do
discovery_url_default_options.merge(discovery_url_options[endpoint.to_sym] || {})
end
Expand Down
19 changes: 1 addition & 18 deletions spec/controllers/discovery_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,28 +212,11 @@ def controller.logout_url
'subject' => 'user@example.com',
'links' => [
'rel' => 'http://openid.net/specs/connect/1.0/issuer',
'href' => 'http://test.host/',
'href' => 'dummy',
],
}.sort)
end

context 'when the discovery_url_options option is set for webfinger endpoint' do
before do
Doorkeeper::OpenidConnect.configure do
discovery_url_options do |request|
{ webfinger: { host: 'alternate-webfinger.host' } }
end
end
end

it 'uses the discovery_url_options option when generating the webfinger endpoint url' do
get :webfinger, params: { resource: 'user@example.com' }
data = JSON.parse(response.body)

expect(data['links'].first['href']).to eq 'http://alternate-webfinger.host/'
end
end

context 'when the discovery_url_options option uses the request for an endpoint' do
before do
Doorkeeper::OpenidConnect.configure do
Expand Down