MCPcopy Index your code
hub / github.com/coder/coder / scimVerifyAuthHeader

Method scimVerifyAuthHeader

enterprise/coderd/scim.go:29–39  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

27)
28
29func (api *API) scimVerifyAuthHeader(r *http.Request) bool {
30 bearer := []byte("bearer ")
31 hdr := []byte(r.Header.Get("Authorization"))
32
33 // Use toLower to make the comparison case-insensitive.
34 if len(hdr) >= len(bearer) && subtle.ConstantTimeCompare(bytes.ToLower(hdr[:len(bearer)]), bearer) == 1 {
35 hdr = hdr[len(bearer):]
36 }
37
38 return len(api.SCIMAPIKey) != 0 && subtle.ConstantTimeCompare(hdr, api.SCIMAPIKey) == 1
39}
40
41func scimUnauthorized(rw http.ResponseWriter) {
42 _ = handlerutil.WriteError(rw, scim.NewHTTPError(http.StatusUnauthorized, "invalidAuthorization", xerrors.New("invalid authorization")))

Callers 5

scimGetUsersMethod · 0.95
scimGetUserMethod · 0.95
scimPostUserMethod · 0.95
scimPatchUserMethod · 0.95
scimPutUserMethod · 0.95

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected