Repository navigation
Conversation
|
as i am learning lua for the first time so that is the reason i got late in solving the bug @Baoyuantop sir and looking for feedback also. |
| api_ctx.var.upstream_uri = core.utils.uri_safe_encode(uri) | ||
| -- after ';'. URI-encode it and store separately so $is_args$args can | ||
| -- be appended after rewrite and access plugin phases complete. | ||
| api_ctx.servlet_upstream_uri = core.utils.uri_safe_encode(uri) |
There was a problem hiding this comment.
Early plugins lose servlet path parameters
With servlet normalization enabled, upstream_uri stays empty during rewrite and access plugins. The external pre-request runner sees a stripped path, and GraphQL introspection can target a different endpoint than the forwarded request.
Example: For /anything;jsessionid=x, the pre-request runner now receives /anything; the upstream receives /anything;jsessionid=x. A GraphQL endpoint available only at the latter path fails schema discovery at the former path.
10d3107 to
c1fd74f
Compare
|
Hi @Baoyuantop,looking for another feedback! I've updated the PR so that I also added a regression test in |
|
Hi @Baoyuantop sir can you look a minute for my pr it will be really great if you provide some feedback |
|
hey @Baoyuantop sir can you please look for the above pr and give me feedback for it |
| not api_ctx.var.upstream_uri or api_ctx.var.upstream_uri == "" then | ||
| api_ctx.var.upstream_uri = api_ctx.servlet_upstream_uri | ||
| .. (api_ctx.var.is_args or "") | ||
| .. (api_ctx.var.args or "") |
There was a problem hiding this comment.
Thanks for the update. I compared base e14c6e93 with head c1fd74f6: query preservation and hide_credentials work as expected, but appending the query here introduces a data-mask interaction.
With normalize_uri_like_servlet enabled, configure data-mask to remove the password query parameter and log $request_line together with $upstream_uri. For /anything;jsessionid=x?password=secret, I get:
base: request_line="GET /anything HTTP/1.1" upstream_uri="/anything;jsessionid=x"
head: request_line="GET /anything HTTP/1.1" upstream_uri="/anything;jsessionid=x?password=secret"
data-mask does not sanitize $upstream_uri during its log phase, so the password remains in the log even when $request has been replaced with the masked $request_line. This is separate from the existing raw $request behavior.
Could you handle this field during log masking and add a regression test for this combination?
|
Ok @ruanweihong-aaa sir i will look for that and update the pr |
c1fd74f to
5b8b473
Compare
|
Hi @ruanweihong-aaa,
Could you please take another look? |
|
Thanks for the update! The original masking case is fixed in targeted HTTP integration tests against
if next(args) then
ctx.var.upstream_uri = upstream_path .. "?" .. core.string.encode_args(args)
else
ctx.var.upstream_uri = upstream_path
endThis replaces the upstream query with the masked request args, dropping parameters added by
uri = "/data-mask/*",But TEST 8 and TEST 10 (lines 268 and 314) request: These normalize to I verified these results with targeted HTTP integration checks comparing |
…vlet URI normalization Fixes apache#13983
5b8b473 to
155d6a0
Compare
|
Hi @ruanweihong-aaa ,
Could you please take another look when you have a moment? |
|
Hi @Ankit-cs , Could you merge the latest master into your PR branch, resolve the conflicts, and push the updated branch? This will help us continue the review. |
|
OK @hanzhenfang sir .Please take another look when you have time, thanks! |
…eserve-query-during-servlet-normalization # Conflicts: # apisix/init.lua # t/router/servlet-upstream-uri.t
Description
Background & Problem:
When
apisix.normalize_uri_like_servletis enabled,$upstream_uriwas materialized before routerewriteandaccessplugins executed.Some plugins modify the request arguments dynamically during these later phases. For example,
key-authandjwt-authremove query credentials viacore.request.set_uri_args()whenhide_credentials: trueis configured. Because$upstream_urialready contained a snapshot of the earlier query string, those query modifications were not reflected in the URI forwarded upstream, causing credentials to leak and query argument changes to be lost.Solution:
api_ctx.servlet_upstream_uriinstead of eagerly writing toapi_ctx.var.upstream_uri.$upstream_uriwith the updated$is_args$argsafter therewriteandaccessplugin phases have completed.proxy-rewriteexplicitly setsapi_ctx.var.upstream_uri, do not overwrite it.proxy-mirrorto also respectservlet_upstream_uri.t/router/servlet-upstream-uri.tcovering:apisix.normalize_uri_like_servlet: truekey-authwithhide_credentials: true?when all arguments are stripped.Which issue(s) this PR fixes:
Fixes #13983
Checklist