[v1.x] Bind transport sessions to the authenticated principal#2719
Merged
Conversation
739fa13 to
072d8d5
Compare
felixweinberger
approved these changes
May 29, 2026
Both HTTP transports now record the principal that created each session — the OAuth client together with the issuer and subject when the token verifier supplies them — and serve subsequent requests for that session only when they present the same principal. Requests presenting a different principal receive the same 404 response as for an unknown session ID, and SSE session entries are removed when the connection ends. Servers without authentication, and authentication backends other than the built-in BearerAuthBackend, are unaffected: no principal is recorded and the comparison always passes.
072d8d5 to
97d5b38
Compare
felixweinberger
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v1.x backport of #2718.
Summary
The Streamable HTTP and SSE transports now record the principal that created each session — the OAuth client together with the issuer and subject when the token verifier supplies them — and serve subsequent requests for that session only when they present the same principal. Requests presenting a different principal receive the same 404 response as for an unknown session ID. SSE session entries are also removed when the connection ends rather than retained for the lifetime of the transport.
Differences from #2718
mainhas a strict-coverage gate that the in-process SSE tests bring into play, so #2718 also adds an SSE round-trip test, edge-case tests,tests/server/test_transport_security.py, and removesno coverpragmas. v1.x has no such gate, so this PR carries only the credential-binding tests.Behaviour
Same as #2718.
Breaking changes
None for default deployments. A hand-rolled SSE setup that applies
BearerAuthBackendonly to the POST route and not the GET route would now reject every message;FastMCPapplies auth at the app level and is unaffected.AI Disclaimer