Ankit-cs opened a new pull request, #14040:
URL: https://github.com/apache/apisix/pull/14040

   ### Description
   
   #### Background & Problem:
   When `apisix.normalize_uri_like_servlet` is enabled, `$upstream_uri` was 
materialized before route `rewrite` and `access` plugins executed. 
   
   Some plugins modify the request arguments dynamically during these later 
phases. For example, `key-auth` and `jwt-auth` remove query credentials via 
`core.request.set_uri_args()` when `hide_credentials: true` is configured. 
Because `$upstream_uri` already 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:
   1. Store the normalized servlet path separately in 
`api_ctx.servlet_upstream_uri` instead of eagerly writing to 
`api_ctx.var.upstream_uri`.
   2. Assemble `$upstream_uri` with the updated `$is_args$args` after the 
`rewrite` and `access` plugin phases have completed.
   3. Respect plugin precedence: if a plugin like `proxy-rewrite` explicitly 
sets `api_ctx.var.upstream_uri`, do not overwrite it.
   4. Updated `proxy-mirror` to also respect `servlet_upstream_uri`.
   5. Added regression test cases in `t/router/servlet-upstream-uri.t` covering:
      - `apisix.normalize_uri_like_servlet: true`
      - query-based `key-auth` with `hide_credentials: true`
      - unrelated query arguments remaining intact
      - clean URI with no trailing `?` when all arguments are stripped.
   
   #### Which issue(s) this PR fixes:
   Fixes #13983
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change (Documentation 
unchanged: this is a bug fix restoring expected behavior)
   - [x] I have verified that this change is backward compatible
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to