Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Enrich unauthorized logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gossion committed Feb 7, 2021
1 parent 80d42d0 commit 3fabc1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/commands/root/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ func (s ServeMuxWithAuth) authHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
info, ok, err := s.auth.AuthenticateRequest(req)
if err != nil {
log.G(s.ctx).Infof("Unauthorized, err: %s", err)
log.G(s.ctx).Infof("Unauthorized, err: %s, RequestURI:%s, UserAgent:%s", err, req.RequestURI, req.UserAgent())
resp.WriteHeader(http.StatusUnauthorized)
resp.Write([]byte("Unauthorized"))

return
}
if !ok {
log.G(s.ctx).Infof("Unauthorized, ok: %t", ok)
log.G(s.ctx).Infof("Unauthorized, ok: %t, RequestURI:%s, UserAgent:%s", ok, req.RequestURI, req.UserAgent())
resp.WriteHeader(http.StatusUnauthorized)
resp.Write([]byte("Unauthorized"))

Expand Down

0 comments on commit 3fabc1c

Please sign in to comment.