1
0

005_auth_throttle.sql 951 B

1234567891011121314151617181920212223
  1. -- R01-N06: persistent per-(ip, email) throttle for /auth/local.
  2. --
  3. -- The local-admin sign-in path had no rate limiting — an attacker could
  4. -- brute-force the password as fast as the server could respond. Audit rows
  5. -- captured each attempt but nothing blocked the next one.
  6. --
  7. -- One row per (ip_address, email) pair seen with a recent failure. Counter
  8. -- is reset on a successful login (DELETE) and naturally rolls over after a
  9. -- 15-minute idle window. Lock thresholds are policy code in
  10. -- AuthThrottleRepository::computeLockout(); the table stores only counts +
  11. -- timestamps.
  12. CREATE TABLE auth_throttle (
  13. ip_address TEXT NOT NULL,
  14. email TEXT NOT NULL,
  15. attempts INTEGER NOT NULL DEFAULT 0,
  16. first_failure_at TEXT NOT NULL,
  17. last_failure_at TEXT NOT NULL,
  18. locked_until TEXT,
  19. PRIMARY KEY (ip_address, email)
  20. );
  21. CREATE INDEX idx_auth_throttle_locked ON auth_throttle(locked_until);