Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OIDC: Fix issues with subset of services. #1304

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed trailing slash on routing policy [PR #1298](https://github.com/3scale/APIcast/pull/1298) [THREESCALE-7146](https://issues.redhat.com/browse/THREESCALE-7146)
- Fixed race condition on caching mode [PR #1259](https://github.com/3scale/APIcast/pull/1259) [THREESCALE-4464](https://issues.redhat.com/browse/THREESCALE-4464)
- Fixed Nginx filter issues on jsonschema [PR #1302](https://github.com/3scale/APIcast/pull/1302) [THREESCALE-7349](https://issues.redhat.com/browse/THREESCALE-7349)
- Fixed issues with OIDC filters [PR #1304](https://github.com/3scale/APIcast/pull/1304) [THREESCALE-6042](https://issues.redhat.com/browse/THREESCALE-6042)


### Added
Expand Down
3 changes: 2 additions & 1 deletion gateway/src/apicast/configuration_loader/oidc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function _M.call(...)
for i,service in ipairs(config.services or empty) do
-- Assign false instead of nil to avoid sparse arrays. cjson raises
-- an error by default when converting sparse arrays.
oidc[i] = oidc[i] or load_service(service) or false
oidc[i] = oidc[i] or load_service(service) or { service_id = service.id}
-- oidc[i] = oidc[i] or load_service(service) or false
end

config.oidc = oidc
Expand Down
17 changes: 15 additions & 2 deletions t/apicast-subset-of-services.t
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ use JSON qw(to_json);

to_json({
services => [
{
id => 12,
backend_version => '1',
proxy => {
api_backend => "http://test:$TEST_NGINX_SERVER_PORT/",
hosts => ["null.com"],
proxy_rules => [
{ pattern => '/', http_method => 'GET', metric_system_name => 'hits', delta => 1 }
]
}
},
{
id => 24,
backend_version => 'oauth',
Expand Down Expand Up @@ -231,8 +242,10 @@ to_json({
}
}
],
oidc => [{
service_id => 24,
oidc => [
{service_id => 12},
{
service_id => 24,
issuer => 'https://example.com/auth/realms/apicast_zero',
config => { id_token_signing_alg_values_supported => [ 'RS256' ] },
keys => { somekid => { pem => $::public_key } },
Expand Down
2 changes: 1 addition & 1 deletion t/configuration-loading-when-needed.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ content_by_lua_block {

--- error_code: 200
--- expected_json
{"services":[{"id":42,"backend_version":1}],"oidc":[false]}
{"services":[{"id":42,"backend_version":1}],"oidc":[{"service_id": 42}]}
--- no_error_log
[error]
6 changes: 3 additions & 3 deletions t/management.t
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ include $TEST_NGINX_MANAGEMENT_CONFIG;
--- request
POST /boot
--- expected_json
{"status":"ok","config":{"oidc":[false],"services":[{"id":42}]}}
{"status":"ok","config":{"oidc":[{"service_id": 42}],"services":[{"id":42}]}}
--- error_code: 200
--- udp_listen random_port env chomp
$TEST_NGINX_RANDOM_PORT
Expand All @@ -198,8 +198,8 @@ include $TEST_NGINX_MANAGEMENT_CONFIG;
--- request eval
['POST /boot', 'POST /boot']
--- expected_json eval
['{"status":"ok","config":{"services":[{"id":42}],"oidc":[false]}}',
'{"status":"ok","config":{"services":[{"id":42}],"oidc":[false]}}']
['{"status":"ok","config":{"services":[{"id":42}],"oidc":[{"service_id": 42}]}}',
'{"status":"ok","config":{"services":[{"id":42}],"oidc":[{"service_id": 42}]}}']
--- error_code eval
[200, 200]
--- udp_listen random_port env chomp
Expand Down