Skip to content

Commit 48e7214

Browse files
authored
Add decoded ID token to extra payload (#19)
When the `openid` scope is requested, an `id_token` is returned by `get_token`. This change adds the decoded `id_token` to the `extra` payload alongside the decoded `access_token`. This approach aligns with common Omniauth strategies and ensures that `id_token` information is available for downstream consumers. Ref: ccrockett#61
1 parent 9fe4bdb commit 48e7214

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/omniauth/strategies/keycloak.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,16 @@ def request_phase
7777
end
7878

7979
extra do
80-
{
81-
'raw_info' => raw_info,
82-
'id_token' => access_token['id_token']
80+
result = {
81+
'raw_info' => raw_info
8382
}
83+
84+
if (id_token = access_token['id_token'])
85+
result['id_token'] = id_token
86+
result['id_info'] = decode_token(id_token)
87+
end
88+
89+
result
8490
end
8591

8692
protected

0 commit comments

Comments
 (0)