diff --git a/CHANGELOG.md b/CHANGELOG.md index 21d5be0b8..9a75c91df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/gateway/src/apicast/configuration_loader/oidc.lua b/gateway/src/apicast/configuration_loader/oidc.lua index ae7b5aba0..8241e7420 100644 --- a/gateway/src/apicast/configuration_loader/oidc.lua +++ b/gateway/src/apicast/configuration_loader/oidc.lua @@ -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 diff --git a/t/apicast-subset-of-services.t b/t/apicast-subset-of-services.t index dc06f5c06..61d0da6d3 100644 --- a/t/apicast-subset-of-services.t +++ b/t/apicast-subset-of-services.t @@ -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', @@ -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 } }, diff --git a/t/configuration-loading-when-needed.t b/t/configuration-loading-when-needed.t index a376b0739..c7ecc47f8 100644 --- a/t/configuration-loading-when-needed.t +++ b/t/configuration-loading-when-needed.t @@ -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] diff --git a/t/management.t b/t/management.t index d9ceab5f2..495171382 100644 --- a/t/management.t +++ b/t/management.t @@ -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 @@ -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