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

Commit 3fabc1c

Browse files
committed
Enrich unauthorized logs
1 parent 80d42d0 commit 3fabc1c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internal/commands/root/mux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ func (s ServeMuxWithAuth) authHandler(h http.Handler) http.Handler {
5858
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
5959
info, ok, err := s.auth.AuthenticateRequest(req)
6060
if err != nil {
61-
log.G(s.ctx).Infof("Unauthorized, err: %s", err)
61+
log.G(s.ctx).Infof("Unauthorized, err: %s, RequestURI:%s, UserAgent:%s", err, req.RequestURI, req.UserAgent())
6262
resp.WriteHeader(http.StatusUnauthorized)
6363
resp.Write([]byte("Unauthorized"))
6464

6565
return
6666
}
6767
if !ok {
68-
log.G(s.ctx).Infof("Unauthorized, ok: %t", ok)
68+
log.G(s.ctx).Infof("Unauthorized, ok: %t, RequestURI:%s, UserAgent:%s", ok, req.RequestURI, req.UserAgent())
6969
resp.WriteHeader(http.StatusUnauthorized)
7070
resp.Write([]byte("Unauthorized"))
7171

0 commit comments

Comments
 (0)