Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion enterprise/coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
if len(options.SCIMAPIKey) != 0 {
api.AGPL.RootHandler.Route("/scim/v2", func(r chi.Router) {
r.Use(
api.scimEnabledMW,
api.RequireFeatureMW(codersdk.FeatureSCIM),
)
r.Post("/Users", api.scimPostUser)
r.Route("/Users", func(r chi.Router) {
Expand All @@ -464,6 +464,13 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
r.Get("/{id}", api.scimGetUser)
r.Patch("/{id}", api.scimPatchUser)
})
r.NotFound(func(w http.ResponseWriter, r *http.Request) {
u := r.URL.String()
httpapi.Write(r.Context(), w, http.StatusNotFound, codersdk.Response{
Message: fmt.Sprintf("SCIM endpoint %s not found", u),
Detail: "This endpoint is not implemented. If it is correct and required, please contact support.",
})
})
})
} else {
// Show a helpful 404 error. Because this is not under the /api/v2 routes,
Expand Down
11 changes: 0 additions & 11 deletions enterprise/coderd/scim.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ import (
"github.com/coder/coder/v2/codersdk"
)

func (api *API) scimEnabledMW(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
if !api.Entitlements.Enabled(codersdk.FeatureSCIM) {
httpapi.RouteNotFound(rw)
return
}

next.ServeHTTP(rw, r)
})
}

func (api *API) scimVerifyAuthHeader(r *http.Request) bool {
hdr := []byte(r.Header.Get("Authorization"))

Expand Down
4 changes: 2 additions & 2 deletions enterprise/coderd/scim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestScim(t *testing.T) {
res, err := client.Request(ctx, "POST", "/scim/v2/Users", struct{}{})
require.NoError(t, err)
defer res.Body.Close()
assert.Equal(t, http.StatusNotFound, res.StatusCode)
assert.Equal(t, http.StatusForbidden, res.StatusCode)
})

t.Run("noAuth", func(t *testing.T) {
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestScim(t *testing.T) {
require.NoError(t, err)
_, _ = io.Copy(io.Discard, res.Body)
_ = res.Body.Close()
assert.Equal(t, http.StatusNotFound, res.StatusCode)
assert.Equal(t, http.StatusForbidden, res.StatusCode)
})

t.Run("noAuth", func(t *testing.T) {
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy