mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-01 04:36:13 +09:00
Add an in-memory (single-worker) per-IP throttle that complements the per-user account lockout: it stops password-spraying across many accounts from one IP and prevents a single attacker draining the shared login rate-limit bucket. - new app/services/auth_throttle_service.py — lock-guarded TTL map with is_blocked / register_failure / reset (+ opportunistic memory sweep) - config: AUTH_IP_MAX_ATTEMPTS (10) / AUTH_IP_WINDOW_MINUTES (15) / AUTH_IP_BLOCK_MINUTES (15) - wire into /login (block up front -> 429 + Retry-After BEFORE the password check; register on bad user/password; reset on correct password), /login-links/redeem, and the 2FA /verify endpoint - per-user lockout and the flask-limiter 5/min decorator kept (defense in depth) - tests: test_login_bruteforce.py (6) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>