Skip to content

Commit 635a735

Browse files
committed
Avoid logging MEE7 requests unless verbose logging is enabled
1 parent 3738f0b commit 635a735

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

auth/heimdall/heimdall.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,24 +253,33 @@ func (a *HeimdallAuth) IsAuthorized(client *types.Client, request *types.Request
253253
log.Printf("[HeimdallAuth] Unauthorized: Missing username\n")
254254
return false, http.StatusUnauthorized
255255
}
256+
logUnauthorized := username != "MEE7" || config.VerboseLogging
256257
token, ok := request.AUTH["TOKEN"]
257258
if !ok {
258-
log.Printf("[HeimdallAuth] Unauthorized: No token provided for %s\n", username)
259+
if logUnauthorized {
260+
log.Printf("[HeimdallAuth] Unauthorized: No token provided for %s\n", username)
261+
}
259262
return false, http.StatusUnauthorized
260263
}
261264
entry, err := a.getAuthEntry(client, username, token)
262265
if err != nil {
263-
log.Printf("[HeimdallAuth] Unauthorized: Could not get auth entry for %s: %+v\n", username, err)
266+
if logUnauthorized {
267+
log.Printf("[HeimdallAuth] Unauthorized: Could not get auth entry for %s: %+v\n", username, err)
268+
}
264269
return false, http.StatusUnauthorized
265270
}
266271

267272
if token != entry.Token {
268-
log.Printf("[HeimdallAuth] Unauthorized: Invalid token for %s\n", username)
273+
if logUnauthorized {
274+
log.Printf("[HeimdallAuth] Unauthorized: Invalid token for %s\n", username)
275+
}
269276
return false, http.StatusUnauthorized
270277
}
271278

272279
if !entry.Permanent && entry.ExpiresAt.Before(time.Now()) {
273-
log.Printf("[HeimdallAuth] Unauthorized: Expired token for %s\n", username)
280+
if logUnauthorized {
281+
log.Printf("[HeimdallAuth] Unauthorized: Expired token for %s\n", username)
282+
}
274283
return false, http.StatusUnauthorized
275284
}
276285

0 commit comments

Comments
 (0)