Add the MCP audience to the gateway provider instead of asking for a second one - #1346
Add the MCP audience to the gateway provider instead of asking for a second one#1346jiaenren wants to merge 1 commit into
Conversation
…second one Enabling MCP required a gateway.envoy.jwt.providers entry carrying the MCP resource URL as its audience. In every deployment that entry was a copy of one already present -- same issuer, same JWKS URI, same claim, same cluster -- differing only in audience, because the relayed upstream token comes from the identity provider already configured for this deployment's own clients. Envoy accepts several audiences per provider, so the resource URL is appended to the entry whose issuer matches the one MCP authenticates against, and no deployment writes the near-identical second entry. The issuer is derivable: OpenID Connect Discovery defines the configuration URL as the issuer followed by /.well-known/openid-configuration. accessTokenIssuer still overrides it for providers whose access tokens are issued elsewhere, as an application configured for v1-format tokens does. The comparison ignores a trailing slash, and an entry already carrying the audience does not get it twice. Failing to find a provider for that issuer now names the issuer rather than saying an entry is required, which was the error a deployer hit after supplying one. Negative-tested by removing the append and confirming the harness fails.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
Consolidated into #1342 to reduce the number of PRs in this stack for review. Adding the MCP audience to the existing gateway provider is the last value a deployer no longer writes. No content is lost: the cumulative diff of the stack against |
Stacked on #1344. Removes the last piece of MCP boilerplate a deployer has to write by hand.
Issue #None
The problem
Enabling MCP required a
gateway.envoy.jwt.providersentry carrying the MCP resource URL as its audience. In every deployment that entry was a copy of one already present — same issuer, same JWKS URI, same claim, same cluster — differing only in audience, because the relayed upstream token comes from the identity provider already configured for this deployment's own clients.A minimal values file failed with:
and the deployer then had to work out five fields, four of which the chart already knew.
The change
Envoy accepts several audiences per provider, so the resource URL is appended to the entry whose issuer matches the one MCP authenticates against. No deployment writes the second entry.
The issuer is derivable: OpenID Connect Discovery defines the configuration URL as the issuer followed by
/.well-known/openid-configuration.accessTokenIssuerstill overrides it for providers whose access tokens are issued elsewhere, as an application configured for v1-format tokens does.Two details worth reviewer attention:
Failing to find a provider for that issuer now names the issuer, rather than saying an entry is required — which was the error a deployer hit after supplying one.
What a deployment writes now
The gateway provider it already needs for its own clients now covers MCP too.
Verification
bazel test //src/service/mcp/... //test/smoke/...passes 76/76render-tests.shpasses, with assertions that the audience is appended to the matching provider, that a provider already carrying it does not get it twice, and that an unset issuer resolves through the configuration URLAlso corrects a stale "either mode" in the deployment guide, left from the direct-mode removal.
🤖 Generated with Claude Code