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

   ## What
   
   `OAuth2Plugin#doExecute` returned an empty `Mono` when:
   - the request had no principal (anonymous),
   - the principal was not an `OAuth2AuthenticationToken`, or
   - `loadAuthorizedClient` returned empty.
   
   The plugin chain was never executed, and the client got an empty 200.
   
   ## Fix
   
   Fall back to the original exchange with `defaultIfEmpty(exchange)`, so the 
request continues down the chain without an `Authorization` header. This 
matches token-relay semantics (Spring Cloud Gateway `TokenRelay` does the
   same). Rejecting unauthenticated requests stays the job of the Spring 
Security filter chain.
   
   ## Tests
   
   - Added `noPrincipal`, `notOAuth2Principal` and `noAuthorizedClient` to 
`OAuth2PluginTest`. Each asserts the chain runs once and no `Authorization` 
header is added.
   - `./mvnw test -pl 
shenyu-plugin/shenyu-plugin-security/shenyu-plugin-oauth2` passes (4 tests, 
with checkstyle and RAT).
   
   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