Skip to content

Commit

Permalink
[oidc] do not useaud JWT claim
Browse files Browse the repository at this point in the history
it might not contain client_id, so better not to use it
#988 (comment)
  • Loading branch information
mikz committed Apr 3, 2019
1 parent 6f6aeb0 commit c4726ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
7 changes: 1 addition & 6 deletions gateway/src/apicast/oauth/oidc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,9 @@ function _M:transform_credentials(credentials, cache_key)

local payload = jwt_obj.payload

local app_id = payload.azp or payload.aud
local app_id = payload.azp
local ttl = timestamp_to_seconds_from_now(payload.exp)


--- http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
-- It MAY also contain identifiers for other audiences.
-- In the general case, the aud value is an array of case sensitive strings.
-- In the common special case when there is one audience, the aud value MAY be a single case sensitive string.
if type(app_id) == 'table' then
app_id = app_id[1]
end
Expand Down
3 changes: 2 additions & 1 deletion spec/oauth/oidc_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ describe('OIDC', function()
header = { typ = 'JWT', alg = 'RS256', kid = 'somekid' },
payload = {
iss = oidc_config.issuer,
aud = {'ce3b2e5e','notused'},
aud = {'notused'},
azp = 'ce3b2e5e',
sub = 'someone',
exp = ngx.now() + 10,
},
Expand Down
2 changes: 1 addition & 1 deletion t/apicast-policy-3scale-batcher.t
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ init_by_lua_block {
--- more_headers eval
use Crypt::JWT qw(encode_jwt);
my $jwt = encode_jwt(payload => {
aud => 'appid',
azp => 'appid',
sub => 'someone',
iss => 'https://example.com/auth/realms/apicast',
exp => time + 3600 }, key => \$::rsa, alg => 'RS256', extra_headers => { kid => 'somekid' });
Expand Down

0 comments on commit c4726ae

Please sign in to comment.