BobSong-dev opened a new pull request, #7811: URL: https://github.com/apache/shenyu/pull/7811
## Background Agent Gateway currently relies on applications to implement `AgentMcpSecurityResolver`. An application that already authenticates requests with Spring Security Resource Server should be able to reuse its verified JWT principal for MCP tools without trusting forwarded headers or installing a second authentication service. ## Changes - Add an opt-in JWT identity bridge. It accepts only an authenticated `JwtAuthenticationToken`, checks the configured issuer and audience, and rejects a principal name that differs from `sub`. Signature, algorithm and lifetime validation remain application responsibilities; the bridge creates no decoder or security filter chain. - Map `tenant_id`, `tool_grants` and `tool_denies` into immutable identity snapshots. Explicit denial wins, and the existing rule allowlist still limits both tool listing and execution. An explicit default tenant applies only when an authenticated token omits `tenant_id`. - Carry the resolved tenant in the request-local Reactor execution context. Keep legacy identity constructors compatible and unassigned to a tenant; do not forward identity headers to remote MCP servers. - Reject multiple identity resolvers even when one is `@Primary`. Keep JWT dependencies optional and the bridge disabled by default; fail startup when explicitly enabled but unavailable. - Document the configuration and add negative authentication, authorization, startup and concurrent request-isolation coverage. This is one identity-adapter feature based directly on merged `master`; it does not depend on #7805. OAuth login/API-key adapters, quotas and broader context/event work are separate. ## Verification - Windows/JDK 17: targeted 15-module `clean verify`, 30 suites / 580 tests, zero failures, errors or skipped tests; Checkstyle and RAT passed in all 15 modules. - RISC-V/QEMU with JDK 17 and `JAVA_TOOL_OPTIONS=-XX:TieredStopAtLevel=1`: the same targeted 15-module `clean verify`, 30 suites / 580 tests, zero failures, errors or skipped tests; Checkstyle and RAT passed in all 15 modules. The first run recorded one failure and one error in existing remote-client timeout tests. Its evidence is retained; the passing run changes only the JVM compilation setting, not source, timeouts or assertions. - The eight JWT HTTP cases use real loopback HTTP and signed JWTs through Spring Security, covering JSON/SSE, invalid authentication, deny/allowlist intersection, explicit tenant fallback and 32 concurrent requests sharing an RPC id with distinct tenants and subjects. These are included in the test total, not additional tests. - Javadoc was skipped. Not run: a full Admin/Bootstrap deployment, real-model calls or full-project Java tests. Remote CI is separate from these local results. -- 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]
