Files
plm-lottery/docs/adr/ADR-41-limitazione-tentativi-su-login-registrazione.md
T
davideandClaude Sonnet 5.5 24e5fc3d8b Bound credentials, brake password changes, cap bug reports, page the user list, structure every error (B-94, SEC-54, SEC-55, API-09, API-15, API-16, API-19, API-21, API-28, API-33, REG-12, AUD-42)
- login and password-change fields: at most 256 characters
- wrong current password: per-user brake (5 free, 2s doubling to 300s), 429 even for the
  right password while locked; password_changed audited in the same transaction
- POST /bug-reports: 10 per IP per hour, consumed only by a stored report
- GET /admin/users: limit/after_id paging, the panel walks the pages
- 401/403/404/405/422/503 all answer {code, message, params}; the 422 omits the input
- static files revalidated on every use (Cache-Control: no-cache)
- error.* keys for the new codes in all seven languages

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 00:59:25 +02:00

1.6 KiB

ADR-41 — Limitazione dei tentativi solo su login e registrazione

  • Stato: Accettata
  • Area: Account, amministrazione e sicurezza
  • Fonte di verità per: la scelta di progetto descritta qui sotto; i requisiti (PREFISSO-NN) che la attuano stanno nei documenti di dominio, indicati nelle Conseguenze.

Decisione

Limitazione dei tentativi solo su login e registrazione, in memoria. Il login usa un ritardo esponenziale per username (dopo 5 errori) e per IP (dopo 20, soglia più alta per non punire una rete condivisa); un login riuscito azzera solo il contatore dello username. La registrazione usa invece una quota di 5 account per IP all'ora, consumata solo dagli account creati davvero. I contatori sono limitati in numero.

  • Motivazione: indovinare una password e creare account in massa sono due problemi diversi (B-33, B-58); il ritardo punisce i tentativi, la quota limita la produzione.
  • Conseguenze: nessun limite su scommesse, prelievi, admin ([LIM-07]). Il cambio password (limitato e registrato come password_changed) e le segnalazioni di bug (limitate per IP) sono limitati (B-94); ogni campo delle credenziali ha una lunghezza massima di 256 caratteri (sicurezza.md, B-94).

Codice: app/auth/rate_limit.py:AuthRateLimiters · app/auth/rate_limit.py:RateLimiter · app/auth/rate_limit.py:RollingQuota · app/auth/routes.py:login · app/api/routes/users.py:change_password · app/api/routes/bug_reports.py:create_bug_report · Test: tests/unit/test_auth.py, tests/unit/test_rate_limit.py, tests/unit/test_abuse_limits.py