Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package api

import (
"fmt"
log "github.com/sirupsen/logrus"
"net/http"

log "github.com/sirupsen/logrus"
)

const tokenMissingMsg = "api token is empty or has not been set. exiting"
Expand All @@ -28,8 +29,10 @@ func (api *API) RequireToken(fn http.HandlerFunc) http.HandlerFunc {
auth := r.Header.Get("Authorization")
want := fmt.Sprintf("Bearer %s", api.Token)
if auth != want {
log.Tracef("Invalid Authorization header \"%s\"", auth)
log.Tracef("Expected Authorization header to be \"%s\"", want)
log.WithFields(log.Fields{
"got": fmt.Sprintf("%q", auth),
"expected": want,
}).Tracef("Invalid Authorization header")
w.WriteHeader(http.StatusUnauthorized)
return
}
Expand Down