(r *http.Request)
| 65 | } |
| 66 | |
| 67 | func (a *API) extractBearerToken(r *http.Request) (string, error) { |
| 68 | authHeader := r.Header.Get("Authorization") |
| 69 | matches := bearerRegexp.FindStringSubmatch(authHeader) |
| 70 | if len(matches) != 2 { |
| 71 | return "", apierrors.NewHTTPError(http.StatusUnauthorized, apierrors.ErrorCodeNoAuthorization, "This endpoint requires a valid Bearer token") |
| 72 | } |
| 73 | |
| 74 | return matches[1], nil |
| 75 | } |
| 76 | |
| 77 | func (a *API) parseJWTClaims(bearer string, r *http.Request) (context.Context, error) { |
| 78 | ctx := r.Context() |