Support RFC 9728 well-known paths with resource components #2197
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.
The previous implementation used exact path matching for the well-known OAuth protected resource metadata endpoint, which only accepted:
/.well-known/oauth-protected-resource
This broke RFC 9728 Section 3.1 compliance for resources with path components. When a resource is identified as "https://server.com/mcp", clients must fetch metadata from:
/.well-known/oauth-protected-resource/mcp
But the exact match would return 404, preventing proper OAuth discovery for MCP servers with path-based resource identifiers.
Changed to prefix matching to support both:
This enables multi-tenant hosting configurations as specified in RFC 9728 and ensures OAuth discovery works correctly for MCP servers regardless of their path structure.
Note: The current implementation accepts all paths under the prefix (e.g., /.well-known/oauth-protected-resource/*). In the future, this could be tightened by having NewAuthInfoHandler parse the request path, extract the resource component, and validate it matches the resourceURL path before returning metadata. This would enforce stricter path matching while maintaining RFC 9728 compliance.