Duansg opened a new pull request, #7967:
URL: https://github.com/apache/shenyu/pull/7967

   ## What
   
   `DefaultJwtConvertStrategy` converts JWT claims into request headers. Three 
behaviors in that conversion are corrected:
   
   - It used `HttpHeaders.add`, which appends. If the request already carried a 
header with the configured `headerVal`, upstream received multiple values and 
`getFirst()` could return the pre-existing one instead of the claim.
   - A missing claim was written as the literal string `"null"`.
   - Nested claim paths returned an intermediate node when the path did not 
match the token: `user.id` against `{"user":"admin"}` resolved to `"admin"`.
   
   ## Changes
   
   - Write claims with `headers.set`, so the configured header always carries 
exactly the claim value. Header names match case-insensitively, and multi-value 
headers are replaced by the single claim value.
   - When a claim is absent or explicitly `null`, remove the header instead of 
writing `"null"`.
   - Rewrite `parse` to walk the claim path once. It returns `null` when any 
node is missing or is not a map. This also removes the per-level entry 
iteration and the `AtomicInteger` allocation.
     
   ## Behavior change
   
   - A request header with the same name as a configured converter `headerVal` 
is now overwritten by the claim value, or removed when the claim is absent.
   - Converter paths that do not match the token structure no longer produce a 
header.
   
   ## Tests
   
   New cases in `DefaultJwtConvertStrategyTest`:
   - an existing header with the same name is replaced by the claim (flat and 
nested)
   - mixed-case and multi-value existing headers collapse to the single claim 
value
   - missing and explicit-null claims remove the existing header (flat and 
nested)
   - a non-map intermediate node (`user.id`, `multi.web.name`) removes the 
header
   
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.


-- 
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