Skip to content

Commit 19d474e

Browse files
committed
refactor(metadata): Update auth server URL based on mode and adjust JWKS URI
Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
1 parent 7ae42b9 commit 19d474e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

internal/oauth/metadata.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,19 @@ func (h *OAuth2Handler) HandleProtectedResourceMetadata(w http.ResponseWriter, r
121121
}
122122

123123
// Return OAuth 2.0 Protected Resource Metadata (RFC 9728)
124-
// Point directly to Okta to remove proxy behavior
124+
// Point to authorization server based on mode
125+
var authServer string
126+
if h.config.Mode == "proxy" {
127+
// Proxy mode: MCP server acts as authorization server
128+
authServer = h.config.MCPURL
129+
} else {
130+
// Native mode: Point directly to OAuth provider
131+
authServer = h.config.Issuer
132+
}
133+
125134
metadata := map[string]interface{}{
126135
"resource": h.config.MCPURL,
127-
"authorization_servers": []string{h.config.Issuer}, // Point directly to Okta - no proxy
136+
"authorization_servers": []string{authServer},
128137
"bearer_methods_supported": []string{"header"},
129138
"resource_signing_alg_values_supported": []string{"RS256"},
130139
"resource_documentation": fmt.Sprintf("%s/docs", h.config.MCPURL),
@@ -284,7 +293,7 @@ func (h *OAuth2Handler) GetAuthorizationServerMetadata() map[string]interface{}
284293
metadata["authorization_endpoint"] = fmt.Sprintf("%s/oauth2/v1/authorize", h.config.Issuer)
285294
metadata["token_endpoint"] = fmt.Sprintf("%s/oauth2/v1/token", h.config.Issuer)
286295
metadata["registration_endpoint"] = fmt.Sprintf("%s/oauth2/v1/clients", h.config.Issuer)
287-
metadata["jwks_uri"] = fmt.Sprintf("%s/.well-known/jwks.json", h.config.Issuer)
296+
metadata["jwks_uri"] = fmt.Sprintf("%s/oauth2/v1/keys", h.config.Issuer)
288297
case "google":
289298
metadata["authorization_endpoint"] = "https://accounts.google.com/o/oauth2/v2/auth"
290299
metadata["token_endpoint"] = "https://oauth2.googleapis.com/token"

0 commit comments

Comments
 (0)