Skip to content

Commit 2436136

Browse files
authored
Merge pull request #34 from rchincha/logs
logs: strip properly
2 parents a1a05a8 + 84b9194 commit 2436136

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

pkg/api/log.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ func Logger(log zerolog.Logger) mux.MiddlewareFunc {
7272
}
7373
clientIP := r.RemoteAddr
7474
method := r.Method
75-
headers := r.Header
76-
delete(headers, "Authorization") // strip from logs
75+
headers := map[string][]string{}
76+
for key, value := range r.Header {
77+
if key == "Authorization" { // anonymize from logs
78+
value = []string{"******"}
79+
}
80+
headers[key] = value
81+
}
7782
statusCode := sw.status
7883
bodySize := sw.length
7984
if raw != "" {

0 commit comments

Comments
 (0)