Add RegisterHandlers and wire embedded AS routes on vMCP mux#4348
Add RegisterHandlers and wire embedded AS routes on vMCP mux#4348
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4348 +/- ##
==========================================
- Coverage 68.86% 68.74% -0.13%
==========================================
Files 479 479
Lines 48505 48530 +25
==========================================
- Hits 33404 33362 -42
+ Misses 12347 12328 -19
- Partials 2754 2840 +86 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Phase 2 of the vMCP embedded authorization server (#4141): - Add RegisterHandlers(mux) to EmbeddedAuthServer — the AS owns its route paths (/oauth/, /.well-known/openid-configuration, etc.) - Add AuthServer field to vMCP server Config - Replace /.well-known/ catch-all with explicit registrations: /.well-known/oauth-protected-resource (exact + subpath) is always registered; Mode B conditionally adds AS discovery/JWKS routes - No commands.go changes — CLI path deferred to Phase 4 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The proxy runner and vMCP server both registered the same four authorization server routes independently. Extract a Routes() method on EmbeddedAuthServer that returns the canonical route map, and have both RegisterHandlers and the proxy runner consume it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
afc069c to
0bd1c80
Compare
|
question: @jhrozek — As scaffolding PRs 3-5 land, the auth surface on
Not blocking — just want to understand the plan before the follow-up PRs land. |
yes, I'd like to land a couple of more PRs but I do have a refactoring planned as the last one. Let me push it up in pauses betweeen review iterations as a draft so you can review. |
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>
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>
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>
Summary
/.well-known/catch-all registration would conflict with AS discovery routes./.well-known/catch-all with explicit/.well-known/oauth-protected-resourcepath registrations so the AS can own its own/.well-known/endpoints without conflicts.RegisterHandlersmethod onEmbeddedAuthServerthat registers/.well-known/openid-configuration,/.well-known/oauth-authorization-server,/.well-known/jwks.json, and/oauth/routes.AuthServerfield tovmcpserver.Configwith nil-guarded route registration in the mux setup.Fixes #4141
Type of change
Test plan
task lint-fix)task test)Changes
pkg/authserver/runner/embeddedauthserver.goRegisterHandlers(mux)methodpkg/vmcp/server/server.goAuthServerfield, explicit.well-known/paths, Mode B route registrationSpecial notes for reviewers
This is part of a stacked PR series for the embedded auth server feature. This PR adds only the server-side wiring points. The construction of the
EmbeddedAuthServerand config loading come in later PRs:Generated with Claude Code