feat(ratelimit): API rate limiting with per-IP and per-user classes (#62) #119
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/kws!119
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/62-rate-limiting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
API-level rate limiting (#62, slice 1): in-memory token buckets per node (
internal/ratelimit), a fixed 429 problem withRetry-After, a correct client IP behind trusted proxies, and six classes:auth_failkws_keypurchasesensitivescanheavydefaultExempt:
/healthz,/readyz, the M-Pesa callback. The gate runs after the route is matched and before the cache; per-user limits wrap theauthenticatefunction given to every module. 429 added to the OpenAPI contract on every classed operation. ADR 0028, CLAUDE.md section, docs/02 proxy text. No migration, no new dependency.Verification
make cover: 91.3% (minimum 80%), run on the final commit (9588207).ratelimitis at 100%.make lint0 issues,make contractok,go test -race -count=1 ./...ok,scripts/generate-clients.shok.Rulings made without you (owner to check, [verify] in ADR 0028)
KWS_TRUSTED_PROXIESis now required in API mode (proxy CIDRs or the literalnone); unset = startup error.make rundefaults it tonone. Production (#57) must set it to the Caddy/Cloudflare ranges, and Caddy must accept only Cloudflare ranges orCF-Connecting-IPis forgeable.kws_key get 429 with no key lookup. Once an IP is blocked its requests also spend the 600/min default cap.Not verified
auth.OIDCVerifieris a follow-up, also for floods spread across many IPv6 /64s.🤖 Generated with Claude Code