Skip to content

Add RFC 8414 path-aware OAuth authorization server metadata endpoint#57

Merged
vitorhugo-java merged 3 commits into
mainfrom
claude/happy-sagan-1wibz2
Jun 9, 2026
Merged

Add RFC 8414 path-aware OAuth authorization server metadata endpoint#57
vitorhugo-java merged 3 commits into
mainfrom
claude/happy-sagan-1wibz2

Conversation

@vitorhugo-java

Copy link
Copy Markdown
Owner

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 OAuthAuthorizationServerMetadataController that handles both root-level and path-aware metadata requests at /.well-known/oauth-authorization-server and /.well-known/oauth-authorization-server/**

    • Ensures "none" (public PKCE clients) is included in token_endpoint_auth_methods_supported and revocation_endpoint_auth_methods_supported
    • Constructs complete OAuth2 metadata response including issuer, endpoints, supported methods, and scopes
  • Security Configuration Updates:

    • Updated AuthorizationServerConfig to explicitly support ClientAuthenticationMethod.NONE in the authorization server metadata customizer
    • Updated SecurityConfig to permit access to /.well-known/oauth-authorization-server/** for metadata discovery
    • Changed /connect/register from permitAll() to denyAll() in both security chains for consistency

Implementation Details

  • The controller uses LinkedHashMap to maintain consistent metadata field ordering
  • Supports both RFC 8414 root endpoint and path-aware variant in a single mapping
  • Integrates with existing AuthorizationServerSettings and McpOAuthProperties for configuration
  • Fallback registration endpoint defaults to /connect/register if not explicitly configured

https://claude.ai/code/session_01KUx3DVuxMyfGQaRCsfVtfx

- 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
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Qodana for JVM

3 new problems were found

Inspection name Severity Problems
Nullability and data flow problems 🔶 Warning 1
Mismatched query and update of 'StringBuilder' 🔶 Warning 1
Simplifiable conditional expression 🔶 Warning 1
View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2025.3.2
        with:
          upload-result: true
Contact Qodana team

Contact 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>
@github-actions github-actions Bot added the tests label Jun 9, 2026
@vitorhugo-java vitorhugo-java merged commit 5ad88df into main Jun 9, 2026
6 checks passed
@vitorhugo-java vitorhugo-java deleted the claude/happy-sagan-1wibz2 branch June 9, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants