fix: move invalid token to log field (#1171)

* 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>
pull/1196/head
nils måsén 3 years ago committed by GitHub
parent 04db93c770
commit be33c64afd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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"
@ -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
}

Loading…
Cancel
Save