Skip to content

Fix: Serve CIMD endpoint when OAuth server protection is enabled#191

Merged
teemow merged 1 commit intomainfrom
fix/cimd-endpoint-oauth-protected
Dec 24, 2025
Merged

Fix: Serve CIMD endpoint when OAuth server protection is enabled#191
teemow merged 1 commit intomainfrom
fix/cimd-endpoint-oauth-protected

Conversation

@teemow
Copy link
Member

@teemow teemow commented Dec 24, 2025

Problem

Two issues with the CIMD endpoint when OAuth server protection is enabled:

Issue 1: CIMD returning 404

The CIMD endpoint (/.well-known/oauth-client.json) was returning 404 when OAuth server protection is enabled.

From mcp-kubernetes logs:

Fetching client metadata from URL: https://muster.gazelle.awsprod.gigantic.io/.well-known/oauth-client.json
status: 404 Not Found

Root cause: The CIMD handler was only mounted in createStandardMux() (used when OAuth server protection is disabled). When enabled, createOAuthProtectedMux() was used instead, which didn't mount the CIMD.

Issue 2: Crashloop due to duplicate route registration

After adding the CIMD, muster was crashlooping with:

panic: pattern "/oauth/callback" conflicts with pattern "/oauth/callback"

Root cause: The OAuth server already registers /oauth/callback, and the OAuth proxy was trying to register the same path.

Solution

  1. Added setupOAuthProxyRoutes() to OAuthHTTPServer.CreateMux() which mounts the self-hosted CIMD at /.well-known/oauth-client.json

  2. Removed the duplicate OAuth callback registration from the proxy - the OAuth server's callback handles both cases since they use the same Dex IdP

Testing

  • All unit tests pass
  • No crashloop after fix

Context

This is part of the OAuth proxy feature that allows muster to authenticate with remote MCP servers (like mcp-kubernetes) on behalf of users.

The CIMD endpoint was only mounted in createStandardMux (used when
OAuth server protection is disabled). When OAuth protection is enabled,
createOAuthProtectedMux was used instead, which didn't mount the CIMD.

Added setupOAuthProxyRoutes to OAuthHTTPServer.CreateMux() which mounts:
- OAuth callback handler for remote server auth
- Self-hosted CIMD at /.well-known/oauth-client.json

The CIMD is served without authentication as it's a public discovery
document that remote MCP servers need to fetch.
@teemow teemow requested a review from a team as a code owner December 24, 2025 15:12
@teemow teemow merged commit 4384f47 into main Dec 24, 2025
3 checks passed
@teemow teemow deleted the fix/cimd-endpoint-oauth-protected branch December 24, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant