chore: return json for disabled scim routes (#15222)

Customers reporting html pages returned to SCIM. Likely a disabled SCIM.
We should just report a more consumable error by the SCIM provider.

Previous behavior was a status code 200 HTML page
This commit is contained in:
Steven Masley
2024-10-24 16:26:16 -04:00
committed by GitHub
parent 81e99bec6b
commit f258232be9
2 changed files with 53 additions and 0 deletions
+12
View File
@@ -465,6 +465,18 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
r.Patch("/{id}", api.scimPatchUser)
})
})
} else {
// Show a helpful 404 error. Because this is not under the /api/v2 routes,
// the frontend is the fallback. A html page is not a helpful error for
// a SCIM provider. This JSON has a call to action that __may__ resolve
// the issue.
// Using Mount to cover all subroute possibilities.
api.AGPL.RootHandler.Mount("/scim/v2", http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusNotFound, codersdk.Response{
Message: "SCIM is disabled, please contact your administrator if you believe this is an error",
Detail: "SCIM endpoints are disabled if no SCIM is configured. Configure 'CODER_SCIM_AUTH_HEADER' to enable.",
})
})))
}
meshTLSConfig, err := replicasync.CreateDERPMeshTLSConfig(options.AccessURL.Hostname(), options.TLSCertificates)