Add RFC 8414 path-aware OAuth authorization server metadata endpoint#57
Merged
Conversation
- Add path-aware /.well-known/oauth-authorization-server/** controller (RFC 8414 §3.1) so ChatGPT's discovery request for the /mcp suffix returns a valid JSON document instead of 404. - Include "none" in token_endpoint_auth_methods_supported via both the new AS metadata controller and the authorizationServerMetadataEndpoint customizer, so ChatGPT does not reject PKCE public-client flows. - Expose /.well-known/oauth-authorization-server/** as a public path in the main security chain. - Lock down /connect/register with denyAll() in both security chains to prevent unauthenticated dynamic client registration. https://claude.ai/code/session_01KUx3DVuxMyfGQaRCsfVtfx
Qodana for JVM3 new problems were found
View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.3.2
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
The previous commit added denyAll() on /connect/register in both security chains, which returned 403 for every request before it could reach the DynamicClientRegistrationController. Per RFC 7591 the DCR endpoint must be publicly accessible; abuse is already mitigated by the per-IP rate limiter in the controller itself (MAX_REGISTRATIONS_PER_MINUTE_PER_IP = 5). Changes: - SecurityConfig: denyAll() → permitAll() for /connect/register - AuthorizationServerConfig: remove dead-code denyAll() (the authorization-server matcher never matches /connect/register since it is not a built-in OAuth2 endpoint)
Agent-Logs-Url: https://github.com/vitorhugo-java/SpringBoot-JobApplyTracker/sessions/73a388a5-8f19-4858-abbe-d7a005cfca44 Co-authored-by: copilot-swe-agent[bot] <198982749+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
This PR adds support for RFC 8414 §3.1 path-aware authorization server metadata discovery, enabling OAuth2 clients like ChatGPT that request metadata with path suffixes (e.g.,
/.well-known/oauth-authorization-server/mcp) to properly discover the authorization server configuration.Key Changes
New Controller: Added
OAuthAuthorizationServerMetadataControllerthat handles both root-level and path-aware metadata requests at/.well-known/oauth-authorization-serverand/.well-known/oauth-authorization-server/**"none"(public PKCE clients) is included intoken_endpoint_auth_methods_supportedandrevocation_endpoint_auth_methods_supportedSecurity Configuration Updates:
AuthorizationServerConfigto explicitly supportClientAuthenticationMethod.NONEin the authorization server metadata customizerSecurityConfigto permit access to/.well-known/oauth-authorization-server/**for metadata discovery/connect/registerfrompermitAll()todenyAll()in both security chains for consistencyImplementation Details
LinkedHashMapto maintain consistent metadata field orderingAuthorizationServerSettingsandMcpOAuthPropertiesfor configuration/connect/registerif not explicitly configuredhttps://claude.ai/code/session_01KUx3DVuxMyfGQaRCsfVtfx