Repository navigation
Description
Summary
With OAuthProxy, a client that obtained a FastMCP access token via the token endpoint cannot revoke it: POST /revoke returns 200 but is a silent no-op — the revocation request is never forwarded to the upstream IdP, and the token remains valid until its exp.
The cause is a client-id mismatch in load_access_token (fastmcp_slim/fastmcp/server/auth/oauth_proxy/proxy.py:2350). The returned AccessToken carries the upstream TokenVerifier's client_id — the upstream IdP's app id, derived from upstream claims (providers/jwt.py:568-573) — while the SDK RevocationHandler ownership gate (mcp/server/auth/handlers/revoke.py) compares it against the MCP client's DCR client_id embedded in the verified FastMCP JWT. Those two values can never be equal, so the gate rejects every FastMCP-token revocation as "not this client's token" and drops it silently. The ID-JAG and refresh-token branches already stamp the DCR client_id onto their returned tokens; only the access-token branch does not.
Concretely: a stolen or leaked FastMCP access token cannot be revoked by its owner even with correct DCR credentials, and RFC 7009's "the authorization server responds with HTTP 200 ... even if the token is already invalid" shape is preserved only by accident — nothing is ever actually revoked.
Repro
Run against an OAuthProxy backed by a test upstream IdP (in-process, using the repo's own OAuthProxy test fixtures):
- DCR-register a client, complete the auth code flow, obtain access + refresh tokens.
POST /revokewith the FastMCP access token and the client's credentials.- Observe: response
200, no request reaches the upstream/revokeendpoint (the upstream mock never matches), and introspecting the token afterwards still says active.
Unit-level view of the mismatch (both values taken from the same proxy instance):
# fastmcp_token = access token minted by the proxy for a DCR client
access = await proxy.load_access_token(fastmcp_token)
print(access.client_id)
# -> 'https://upstream-idp.example/app' (upstream-derived app id)
payload = proxy.jwt_issuer.verify_token(fastmcp_token) # the verified FastMCP JWT (sync; raises on invalid tokens)
print(payload["client_id"])
# -> 'dcr-client' (what the SDK revocation gate compares against
# and what the client actually presents)
Assertion captured from the regression run on current main (commit 7f3c53e):
AssertionError: assert 'https://upst...p.example/app' == 'dcr-client'
- dcr-client
+ https://upstream-idp.example/app
(and from the e2e run: AssertionError: The following responses are mocked but not requested: - Match POST request on https://idp.example.com/revoke — the upstream revocation endpoint was never called.)
Stamping the DCR client_id from the verified FastMCP JWT onto the returned AccessToken at the shared return point (a non-mutating model_copy(update=...), mirroring the ID-JAG/refresh branches) lets the ownership gate match, and the upstream access token is then actually POSTed to the upstream revocation endpoint ({"token": ["upstream-access-token"]}), with the FastMCP token invalidated afterwards. OIDCProxy inherits the same code path.
Activity
fix(auth): keep revocation ownership separate from user identity (Pre…
[4.1] Backport fixes for 4.1.8 (#6415)