Bound every slog line against client-chosen text (closes #176)
All checks were successful
check / check (push) Successful in 2m55s
All checks were successful
check / check (push) Successful in 2m55s
This commit was merged in pull request #180.
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"sneak.berlin/go/webhooker/internal/logfield"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -372,8 +374,17 @@ func (m *Middleware) RecordLoginFailure(
|
||||
) bool {
|
||||
throttled := m.guard().fail(m.clientKey(r), username)
|
||||
if throttled {
|
||||
// Truncated even though chi pins this route's path to
|
||||
// the 12-byte constant "/pages/login": RecordLoginFailure
|
||||
// is exported and takes any *http.Request, so a caller on
|
||||
// a route with a URL parameter would otherwise widen this
|
||||
// line. logbound_test.go pins the cap by making exactly
|
||||
// that call, since no request through the mux can.
|
||||
m.log.Warn(
|
||||
"login failure limit exceeded", "path", r.URL.Path,
|
||||
"login failure limit exceeded",
|
||||
"path", logfield.Truncate(
|
||||
r.URL.Path, logfield.MaxBytes,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user