1 package auth
2 3 import "net/http"
4 5 // Auth implement methods required for authentication.
6 // Valid authentication are currently a token or no auth.
7 type Auth interface {
8 // Headers returns headers that must be add to the http request
9 Headers() http.Header
10 11 // AnonymizedHeaders returns an anonymised version of Headers()
12 // This method could be use for logging purpose.
13 AnonymizedHeaders() http.Header
14 }
15 16 type headerAnonymizer func(header http.Header) http.Header
17 18 var headerAnonymizers = []headerAnonymizer{
19 AnonymizeTokenHeaders,
20 AnonymizeJWTHeaders,
21 }
22 23 func AnonymizeHeaders(headers http.Header) http.Header {
24 for _, anonymizer := range headerAnonymizers {
25 headers = anonymizer(headers)
26 }
27 28 return headers
29 }
30