@@ -30,6 +30,7 @@ func RequireAPIKeyHandler(
|
||||
) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
correlationID := r.Header.Get("X-Request-ID")
|
||||
if correlationID == "" {
|
||||
correlationID = r.Header.Get("X-Correlation-ID")
|
||||
@@ -43,10 +44,12 @@ func RequireAPIKeyHandler(
|
||||
)
|
||||
|
||||
apiKey := authn.APIKeyFromContext(ctx)
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
if identity == nil {
|
||||
w.Header().Set("WWW-Authenticate", "Bearer")
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, errors.New("authentication required"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user