Support RFC 8414 path-based issuer discovery URLs#4406
Merged
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
tgrunnagle
approved these changes
Mar 27, 2026
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
/.well-known/catch-all mux pattern with explicitexact registrations to prevent the auth server from intercepting
/.well-known/oauth-protected-resource(owned by the vMCP server). Thisinadvertently 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.http.ServeMux(
Routes()) and chi router (WellKnownRoutes) so subpaths are routed tothe discovery handlers.
Type of change
Test plan
task test)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 themulti-upstream OAuth flow (Okta + GitHub + Google), and called tools.
Changes
pkg/authserver/runner/embeddedauthserver.goRoutes()for discovery pathspkg/authserver/server/handlers/handler.gopkg/authserver/runner/embeddedauthserver_test.goTestRoutesexpected 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-serverbefore 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