Admin key endpoint: per-IP rate limiting and lockout (#66) #73

Merged
poslop merged 1 commits from issue-66-admin-ratelimit into main 2026-09-09 14:26:14 +00:00
Owner

Fixes #66

Admin endpoint (/admin/api/settings) had no rate limiting or lockout on key attempts.

  • Added rateLimitAdmin: per-IP token bucket, 5 attempts/min, reusing the existing unlock rate limiter mechanism (#34 pattern).
  • adminAuth now returns 429 with Retry-After once the bucket is exhausted, before key comparison; lockout applies to correct keys too (prevents hammering).
  • Verified constant-time key compare (crypto/subtle ConstantTimeCompare) was already in place (#40) — no change needed.
  • Failed attempts were already logged (#40); rate-limited attempts now also logged.

Tests (internal/api/adminratelimit_test.go): hammering bad keys yields 401s then 429 with Retry-After; correct key from same IP is locked out; correct key from a different IP still works; constant-time compare sanity check.

All tests pass (go build ./..., go vet ./..., go test ./...).

## Fixes #66 Admin endpoint (`/admin/api/settings`) had no rate limiting or lockout on key attempts. - Added `rateLimitAdmin`: per-IP token bucket, 5 attempts/min, reusing the existing unlock rate limiter mechanism (#34 pattern). - `adminAuth` now returns 429 with `Retry-After` once the bucket is exhausted, before key comparison; lockout applies to correct keys too (prevents hammering). - Verified constant-time key compare (crypto/subtle ConstantTimeCompare) was already in place (#40) — no change needed. - Failed attempts were already logged (#40); rate-limited attempts now also logged. Tests (`internal/api/adminratelimit_test.go`): hammering bad keys yields 401s then 429 with Retry-After; correct key from same IP is locked out; correct key from a different IP still works; constant-time compare sanity check. All tests pass (`go build ./...`, `go vet ./...`, `go test ./...`).
poslop added 1 commit 2026-09-09 14:15:07 +00:00
admin: per-IP rate limit (5/min) on admin key attempts (#66)
CI / docker (pull_request) Skipped
CI / test (pull_request) Successful in 23s
9811191648
poslop merged commit b600cdf51a into main 2026-09-09 14:26:14 +00:00
Sign in to join this conversation.