Skip to content

Commit

Permalink
fix: move invalid token to log field (#1171)
Browse files Browse the repository at this point in the history
* fix: move invalid token to log field

* escape invalid token in log field

* Update pkg/api/api.go

Co-authored-by: Simon Aronsson <simme@arcticbit.se>
  • Loading branch information
piksel and simskij committed Jan 22, 2022
1 parent 04db93c commit be33c64
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 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,6 @@ 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)
w.WriteHeader(http.StatusUnauthorized)
return
}
Expand Down

0 comments on commit be33c64

Please sign in to comment.