DekEn

อัปเดต 2026-09-07

Login lockout & rate limiting

5 strikes / 15-min lock; slowapi throttling

Login attempts are throttled two ways: a per-account lockout after repeated wrong passwords, and a request-rate limiter on the login endpoint itself — brute-force controls that run before any password is even checked.

เมื่อไรจึงใช้
  • You're documenting login-security controls for a customer InfoSec review
  • You're debugging a 'why is my login blocked' report from a user or from your own testing
  • You're tuning the rate limit for a load test or a bulk-onboarding scenario
คำนวณอย่างไร

Five consecutive wrong passwords lock the account for 15 minutes (checked before the bcrypt verify even runs, so the lockout gate is cheap); separately, POST /auth/login is wrapped with a slowapi rate limiter, default 20 requests / 5 minutes, configurable via the LOGIN_RATE_LIMIT env var.

ข้อควรระวัง
noteThe lockout counter resets only on a successful login — repeatedly retrying a still-wrong password keeps the lock engaged rather than extending a fixed window.
noteFor load testing, set LOGIN_RATE_LIMIT=10000/minute in the environment before the app starts — it's read at import time, so changing it requires a restart, not a live reload.