MCPcopy Create free account
hub / github.com/netlify/gotrue / extractBearerToken

Method extractBearerToken

api/auth.go:62–74  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

60}
61
62func (a *API) extractBearerToken(w http.ResponseWriter, r *http.Request) (string, error) {
63 authHeader := r.Header.Get("Authorization")
64 if authHeader == "" {
65 return "", unauthorizedError("This endpoint requires a Bearer token")
66 }
67
68 matches := bearerRegexp.FindStringSubmatch(authHeader)
69 if len(matches) != 2 {
70 return "", unauthorizedError("This endpoint requires a Bearer token")
71 }
72
73 return matches[1], nil
74}
75
76func (a *API) parseJWTClaims(bearer string, r *http.Request, w http.ResponseWriter) (context.Context, error) {
77 ctx := r.Context()

Callers 2

requireAuthenticationMethod · 0.95

Calls 2

unauthorizedErrorFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected