Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Commit

Permalink
feature: Add supported claims to discovery response
Browse files Browse the repository at this point in the history
  • Loading branch information
toupeira committed Oct 5, 2016
1 parent 2618e04 commit 1d8f9ea
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ Add the following to your config/initializers/doorkeeper_openid_connect.rb:
# expiration 600

claims do
claim :_foo_ do |resource_owner|
normal_claim :_foo_ do |resource_owner|
resource_owner.foo
end

claim :_bar_ do |resource_owner|
normal_claim :_bar_ do |resource_owner|
resource_owner.bar
end
end
Expand Down
16 changes: 16 additions & 0 deletions app/controllers/doorkeeper/openid_connect/discovery_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ def provider_response
id_token_signing_alg_values_supported: [
'RS256',
],

claim_types_supported: [
'normal',

# TODO: support these
#'aggregated',
#'distributed',
],

claims_supported: [
'iss',
'sub',
'aud',
'exp',
'iat',
] | openid_connect.claims.to_h.keys,
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
'id_token_signing_alg_values_supported' => [
'RS256',
],

'claim_types_supported' => [
'normal',
],

'claims_supported' => [
'iss',
'sub',
'aud',
'exp',
'iat',
'name',
],
}.sort)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
get :show, access_token: token.token

expect(response.status).to eq 200
expect(response.body).to eq %Q{{"sub":"#{user.id}"}}
expect(response.body).to eq %Q{{"sub":"#{user.id}","name":"Joe"}}
end
end

Expand Down
4 changes: 4 additions & 0 deletions spec/dummy/config/initializers/doorkeeper_openid_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@
subject do |resource_owner|
resource_owner.id
end

claims do
normal_claim :name, &:name
end
end

0 comments on commit 1d8f9ea

Please sign in to comment.