fix(http): preserve CORS across OAuth routes - #3147
Merged
Merged
Conversation
Apply the browser CORS contract at the root router so authentication, metadata, error, and fallback responses retain the required headers. Register protected-resource metadata for every MCP route variant and verify each challenge round trip.\n\nRefs #3095\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Centralizes CORS handling for all HTTP routes and expands OAuth protected-resource discovery across every MCP route variant.
Changes:
- Apply CORS middleware at the root router.
- Add OAuth metadata routes for readonly, insiders, and toolset combinations.
- Expand contract tests and OAuth/CORS documentation.
Show a summary per file
| File | Description |
|---|---|
pkg/http/server.go |
Centralizes HTTP router construction and CORS handling. |
pkg/http/server_test.go |
Tests CORS and OAuth metadata route contracts. |
pkg/http/oauth/oauth.go |
Adds missing protected-resource route variants. |
pkg/http/oauth/oauth_test.go |
Verifies the complete metadata route matrix. |
pkg/http/middleware/cors.go |
Preserves existing exposed response headers. |
pkg/http/middleware/cors_test.go |
Tests preflight and exposed-header behavior. |
docs/streamable-http.md |
Documents OAuth discovery and browser proxy requirements. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Balanced
Prevent unrecognized protected-resource metadata paths from falling through to the MCP root mount and producing recursive authentication challenges.\n\nRefs #3095\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Summary
WWW-AuthenticateandMcp-Session-Idwithout enabling credentialed wildcard requestsValidation
script/lintscript/testOrigin: https://confer.toHosted dependencies
Addresses the OSS server portion of #3095.