Skip to content

Support RFC 8414 path-based issuer discovery URLs#4406

Merged
jhrozek merged 1 commit intomainfrom
fix/rfc8414-discovery-routing
Mar 27, 2026
Merged

Support RFC 8414 path-based issuer discovery URLs#4406
jhrozek merged 1 commit intomainfrom
fix/rfc8414-discovery-routing

Conversation

@jhrozek
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek commented Mar 27, 2026

Summary

  • PR Add RegisterHandlers and wire embedded AS routes on vMCP mux #4348 replaced the /.well-known/ catch-all mux pattern with explicit
    exact registrations to prevent the auth server from intercepting
    /.well-known/oauth-protected-resource (owned by the vMCP server). This
    inadvertently broke RFC 8414 Section 3.1 discovery for path-based issuers:
    clients construct /.well-known/oauth-authorization-server/{issuer-path}
    but the exact pattern only matched /.well-known/oauth-authorization-server.
  • Register trailing-slash prefix variants on both the http.ServeMux
    (Routes()) and chi router (WellKnownRoutes) so subpaths are routed to
    the discovery handlers.

Type of change

  • Bug fix

Test plan

  • Unit tests (task test)
  • Manual testing (describe below)

Verified end-to-end with a VirtualMCPServer deployed to a kind cluster
behind ngrok with a path-based issuer (https://toolhive.ngrok.app/inject-test).
Claude Code successfully discovered the auth server via
/.well-known/oauth-authorization-server/inject-test, completed the
multi-upstream OAuth flow (Okta + GitHub + Google), and called tools.

Changes

File Change
pkg/authserver/runner/embeddedauthserver.go Add trailing-slash prefix entries to Routes() for discovery paths
pkg/authserver/server/handlers/handler.go Add wildcard chi routes for discovery handlers
pkg/authserver/runner/embeddedauthserver_test.go Update TestRoutes expected count (4 → 6)

Special notes for reviewers

The regression was introduced in #4348 which correctly avoided a /.well-known/
catch-all but did not account for RFC 8414 Section 3.1 where clients insert
/.well-known/oauth-authorization-server before the issuer's path component.
This only manifests when the issuer has a path (e.g., multi-tenant deployments
behind a shared domain). Issuers at the domain root are unaffected.

Generated with Claude Code

PR #4348 (f64d807) replaced the /.well-known/ catch-all mux pattern
with explicit exact registrations to prevent the auth server from
intercepting /.well-known/oauth-protected-resource. This broke RFC 8414
Section 3.1 discovery for path-based issuers: clients construct
/.well-known/oauth-authorization-server/{issuer-path} but the exact
pattern only matched /.well-known/oauth-authorization-server.

Register trailing-slash prefix variants on both the http.ServeMux
(Routes()) and chi router (WellKnownRoutes) so subpaths are routed
to the discovery handlers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Mar 27, 2026
@jhrozek jhrozek requested a review from tgrunnagle March 27, 2026 15:07
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.50%. Comparing base (d57d73b) to head (af368e1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4406   +/-   ##
=======================================
  Coverage   69.49%   69.50%           
=======================================
  Files         485      485           
  Lines       49841    49845    +4     
=======================================
+ Hits        34638    34645    +7     
+ Misses      12528    12525    -3     
  Partials     2675     2675           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhrozek jhrozek merged commit e62f833 into main Mar 27, 2026
40 checks passed
@jhrozek jhrozek deleted the fix/rfc8414-discovery-routing branch March 27, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants