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

PATH-routing: url was not escaped correctly #1150

Merged
merged 1 commit into from
Dec 20, 2019
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Now the configuration of the issuer is cached to avoid flip-flop issues when OIDC connectivity fails. [THREESCALE-3809](https://issues.jboss.org/browse/THREESCALE-3809) [PR #1141](https://github.com/3scale/APIcast/pull/1141)
- Now the configuration of the issuer is cached to avoid flip-flop issues when OIDC connectivity fails. [THREESCALE-3809](https://issues.jboss.org/browse/THREESCALE-3809) [PR #1141](https://github.com/3scale/APIcast/pull/1141)

### Fixed

- When PATH routing was enabled the URL was not correctly escaped [THREESCALE-3468](https://issues.jboss.org/browse/THREESCALE-3468) [PR #1150](https://github.com/3scale/APIcast/pull/1150)


### Fixed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
local mapping_rules_matcher = require 'apicast.mapping_rules_matcher'
local escape = require("resty.http.uri_escape")

local _M = {}

function _M.find_service(config_store, host)
local found
local services = config_store:find_by_host(host)
local method = ngx.req.get_method()
local uri = ngx.var.uri
local uri = escape.escape_uri(ngx.var.uri)

for s=1, #services do
local service = services[s]
Expand Down
81 changes: 81 additions & 0 deletions t/apicast-path-routing.t
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,84 @@ Host: one
--- error_code: 404
--- no_error_log
[error]

=== TEST 4: multi service configuration with path based routing and special chars (spaces)
--- env eval
('APICAST_PATH_ROUTING' => '1')
--- configuration
{
"services": [
{
"id": 42,
"backend_version": 1,
"proxy": {
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/api-backend/foo/",
"hosts": [
"same"
],
"backend_authentication_type": "service_token",
"backend_authentication_value": "service-one",
"proxy_rules": [
{
"pattern": "/one/{test}",
"http_method": "GET",
"metric_system_name": "one",
"delta": 1
}
]
}
},
{
"id": 21,
"backend_version": 2,
"proxy": {
"api_backend": "http://test:$TEST_NGINX_SERVER_PORT/api-backend/bar/",
"hosts": [
"same"
],
"backend_authentication_type": "service_token",
"backend_authentication_value": "service-two",
"proxy_rules": [
{
"pattern": "/two/%20two",
"http_method": "GET",
"metric_system_name": "two",
"delta": 2
},
{
"pattern": "/two/%20two/test",
"http_method": "GET",
"metric_system_name": "two",
"delta": 2
}
]
}
}
]
}
--- backend
location /transactions/authrep.xml {
content_by_lua_block { ngx.exit(200) }
}
--- upstream
location ~ /api-backend(/.+) {
echo 'yay, api backend: $1';
}
--- request eval
[
"GET /one/12%2012?user_key=one-key",
"GET /two/%20two?app_id=two-id&app_key=two-key",
"GET /two/%20two/test?app_id=two-id&app_key=two-key"
]
--- more_headers eval
["Host: same", "Host: same", "Host: same"]
--- response_body eval
[
"yay, api backend: /foo/one/12 12\x{0a}",
"yay, api backend: /bar/two/ two\x{0a}",
"yay, api backend: /bar/two/ two/test\x{0a}"
]
--- error_code eval
[200, 200, 200]
--- no_error_log
[error]