You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
feat: add RFC 9728 OAuth2 resource metadata support (#18920)
# Enhanced OAuth2 and MCP Compliance for API AuthenticationThis PR improves OAuth2 and MCP (Microsoft Cloud for Sovereignty)compliance by:1. Adding RFC 9728 compliant `WWW-Authenticate` headers with resourcemetadata URLs2. Passing the configured `AccessURL` to API key middleware for properaudience validation3. Creating specialized CORS handling for OAuth2 and MCP endpoints withappropriate headers4. Making the `state` parameter optional in OAuth2 authorizationrequestsThese changes ensure proper OAuth2 token audience validation against theconfigured access URL and improve interoperability with OAuth2 clientsby providing better error responses and metadata discovery.Signed-off-by: Thomas Kosiewski <tk@coder.com>
wwwAuth=`Bearer realm="coder", error="invalid_token", error_description="The access token audience does not match this resource"`
229
-
default:
230
-
wwwAuth=`Bearer realm="coder", error="invalid_token", error_description="The access token is invalid"`
231
-
}
232
-
casehttp.StatusForbidden:
233
-
// Map 403 to insufficient_scope per RFC 6750
234
-
wwwAuth=`Bearer realm="coder", error="insufficient_scope", error_description="The request requires higher privileges than provided by the access token"`
returnfmt.Sprintf(`Bearer realm="coder", error="invalid_token", error_description="The access token audience does not match this resource", resource_metadata=%q`,resourceMetadata)
636
+
default:
637
+
returnfmt.Sprintf(`Bearer realm="coder", error="invalid_token", error_description="The access token is invalid", resource_metadata=%q`,resourceMetadata)
638
+
}
639
+
casehttp.StatusForbidden:
640
+
returnfmt.Sprintf(`Bearer realm="coder", error="insufficient_scope", error_description="The request requires higher privileges than provided by the access token", resource_metadata=%q`,resourceMetadata)