mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
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>
This commit is contained in:
parent
04db93c770
commit
be33c64afd
1 changed files with 2 additions and 3 deletions
|
|
@ -2,8 +2,9 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const tokenMissingMsg = "api token is empty or has not been set. exiting"
|
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")
|
auth := r.Header.Get("Authorization")
|
||||||
want := fmt.Sprintf("Bearer %s", api.Token)
|
want := fmt.Sprintf("Bearer %s", api.Token)
|
||||||
if auth != want {
|
if auth != want {
|
||||||
log.Tracef("Invalid Authorization header \"%s\"", auth)
|
|
||||||
log.Tracef("Expected Authorization header to be \"%s\"", want)
|
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue