(w http.ResponseWriter, r *http.Request)
| 60 | } |
| 61 | |
| 62 | func (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 | |
| 76 | func (a *API) parseJWTClaims(bearer string, r *http.Request, w http.ResponseWriter) (context.Context, error) { |
| 77 | ctx := r.Context() |
no test coverage detected