Repository navigation
fix(mcp): preserve the OAuth client and resource through exchange - #2665
Conversation
Signed-off-by: Alex Gercog <[email protected]>
|
Warning
Pull request policy: Only bug fixes may be opened as pull requests. |
|
No actionable comments were generated in the recent review. WalkthroughThe console and MCP OAuth authorization-code flows now retain an optional resource value and pass it to token exchange when present. The MCP flow also stores its OAuth client in flow state. Token refresh includes the resource when it is a nonempty string. ChangesOAuth resource forwarding
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant Callback
participant MCPAuthenticationFlowHandler
participant flow_state.client
participant TokenEndpoint
Callback->>MCPAuthenticationFlowHandler: authorization code and OAuth state
MCPAuthenticationFlowHandler->>flow_state.client: fetch_token with code, state, and optional resource
flow_state.client->>TokenEndpoint: token request
TokenEndpoint-->>flow_state.client: token response
Possibly related PRs
Merge Risk:
|
|
/ok to test 21c3fe6 |
|
/merge |
1 similar comment
|
/merge |
Description
MCPAuthenticationFlowHandlernever stored the OAuth client in its per-flow state. The redirect route inherited from the console handler then calledfetch_tokenonNone, and the MCP browser sign-in failed at the callback. #2165 moved the client into the per-flow state for the console handler. This applies the same to the MCP override.When the authorization request carries a
resourceparameter, the code exchange and the token refresh now send the same value. A flow without aresourcesends the same parameters as before. The client secret handling from #2626 is unchanged.On
developthree of the five targeted callback and refresh tests fail. With this change all five pass.ci/scripts/run_tests.pypasses the same tests in the MCP project (2) and the core project (3). The tests use a stub token endpoint and an in-process ASGI transport. A live authorization server was not used.Closes #2662
By Submitting this PR I confirm:
Summary by CodeRabbit