Skip to content

Commit

Permalink
Add grant_types_supported to discovery response
Browse files Browse the repository at this point in the history
  • Loading branch information
linhdangduy committed May 25, 2020
1 parent e8ce8fa commit 9842b58
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

- [#114] Fix user_info endpoint when used in api mode
- [#112] Add grant_types_supported to discovery response

## v1.7.2 (2020-05-20)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def provider_response
# TODO: support id_token response type
response_types_supported: doorkeeper.authorization_response_types,
response_modes_supported: ['query', 'fragment'],
grant_types_supported: grant_types_supported(doorkeeper),

token_endpoint_auth_methods_supported: [
'client_secret_basic',
Expand Down Expand Up @@ -73,6 +74,12 @@ def provider_response
}.compact
end

def grant_types_supported(doorkeeper)
grant_types_supported = doorkeeper.grant_flows
grant_types_supported << 'refresh_token' if doorkeeper.refresh_token_enabled?
grant_types_supported
end

def webfinger_response
{
subject: params.require(:resource),
Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/discovery_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

'response_types_supported' => ['code'],
'response_modes_supported' => ['query', 'fragment'],
'grant_types_supported' => %w[authorization_code client_credentials],

'token_endpoint_auth_methods_supported' => [
'client_secret_basic',
Expand Down Expand Up @@ -57,6 +58,17 @@
}.sort)
end

context 'when refresh_token grant type is enabled' do
before { Doorkeeper.configure { use_refresh_token } }

it 'add refresh_token to grant_types_supported' do
get :provider
data = JSON.parse(response.body)

expect(data['grant_types_supported']).to eq %w[authorization_code client_credentials refresh_token]
end
end

it 'uses the protocol option for generating URLs' do
Doorkeeper::OpenidConnect.configure do
protocol { :testing }
Expand Down

0 comments on commit 9842b58

Please sign in to comment.