Skip to content

Commit 9d8a83e

Browse files
authored
Merge pull request #1007 from 3scale/oidc-aud-check
[oidc] do not use`aud` JWT claim [THREESCALE-2263]
2 parents d9d03c4 + 8b5e18c commit 9d8a83e

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lua_modules/
1010
tmp/benchmark/
1111
.bash_history
1212
.cache/
13+
.cpanm
1314
/vendor/cache
1415
/.docker
1516
/tmp/

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Fixed incorrect description of the `client` attribute in the Keycloak role check policy [PR #1005](https://github.com/3scale/APIcast/pull/1005), [THREESCALE_1867](https://issues.jboss.org/browse/THREESCALE-1867)
1616
- Segfault when normalizing some client certificates [PR #1006](https://github.com/3scale/APIcast/pull/1006)
1717

18+
### Removed
19+
20+
- Checking `aud` JWT claim for app_id when using OIDC integration [PR #1007](https://github.com/3scale/APIcast/pull/1007)
21+
1822
## [3.5.0-rc1] - 2019-03-29
1923

2024
### Changed

gateway/src/apicast/oauth/oidc.lua

+1-6
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,9 @@ function _M:transform_credentials(credentials, cache_key)
195195

196196
local payload = jwt_obj.payload
197197

198-
local app_id = payload.azp or payload.aud
198+
local app_id = payload.azp
199199
local ttl = timestamp_to_seconds_from_now(payload.exp)
200200

201-
202-
--- http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
203-
-- It MAY also contain identifiers for other audiences.
204-
-- In the general case, the aud value is an array of case sensitive strings.
205-
-- In the common special case when there is one audience, the aud value MAY be a single case sensitive string.
206201
if type(app_id) == 'table' then
207202
app_id = app_id[1]
208203
end

spec/oauth/oidc_spec.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ describe('OIDC', function()
7474
header = { typ = 'JWT', alg = 'RS256', kid = 'somekid' },
7575
payload = {
7676
iss = oidc_config.issuer,
77-
aud = {'ce3b2e5e','notused'},
77+
aud = {'notused'},
78+
azp = 'ce3b2e5e',
7879
sub = 'someone',
7980
exp = ngx.now() + 10,
8081
},

t/apicast-oidc.t

+8-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ to_json({
5151
--- more_headers eval
5252
use Crypt::JWT qw(encode_jwt);
5353
my $jwt = encode_jwt(payload => {
54-
aud => 'appid',
54+
aud => 'something',
55+
azp => 'appid',
5556
sub => 'someone',
5657
iss => 'https://example.com/auth/realms/apicast',
5758
exp => time + 3600 }, key => \$::private_key, alg => 'RS256', extra_headers => { kid => 'somekid' });
@@ -106,7 +107,8 @@ to_json({
106107
--- more_headers eval
107108
use Crypt::JWT qw(encode_jwt);
108109
my $jwt = encode_jwt(payload => {
109-
aud => 'appid',
110+
aud => 'something',
111+
azp => 'appid',
110112
sub => 'someone',
111113
iss => 'https://example.com/auth/realms/apicast',
112114
exp => time + 3600 }, key => \$::private_key, alg => 'RS256', extra_headers => { kid => 'somekid' });
@@ -145,7 +147,8 @@ to_json({
145147
--- more_headers eval
146148
use Crypt::JWT qw(encode_jwt);
147149
my $jwt = encode_jwt(payload => {
148-
aud => 'appid',
150+
aud => 'something',
151+
azp => 'appid',
149152
sub => 'someone',
150153
iss => 'https://example.com/auth/realms/apicast',
151154
exp => time + 3600 }, key => \$::private_key, alg => 'RS256', extra_headers => { kid => 'somekid' });
@@ -199,7 +202,8 @@ to_json({
199202
--- more_headers eval
200203
use Crypt::JWT qw(encode_jwt);
201204
my $jwt = encode_jwt(payload => {
202-
aud => 'appid',
205+
aud => 'something',
206+
azp => 'appid',
203207
sub => 'someone',
204208
iss => 'https://example.com/auth/realms/apicast',
205209
exp => time + 3600 }, key => \$::private_key, alg => 'RS256', extra_headers => { kid => 'somekid' });

t/apicast-policy-3scale-batcher.t

+2-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ init_by_lua_block {
610610
--- more_headers eval
611611
use Crypt::JWT qw(encode_jwt);
612612
my $jwt = encode_jwt(payload => {
613-
aud => 'appid',
613+
aud => 'something',
614+
azp => 'appid',
614615
sub => 'someone',
615616
iss => 'https://example.com/auth/realms/apicast',
616617
exp => time + 3600 }, key => \$::rsa, alg => 'RS256', extra_headers => { kid => 'somekid' });

0 commit comments

Comments
 (0)