This repository was archived by the owner on Jul 10, 2026. It is now read-only.
Sprint 1 (backend): throttle de login por IP em Redis (TKT-017) - #109
Merged
Conversation
Move o throttle de brute-force de login do DashMap in-process para Redis, tornando-o distribuido (varias replicas da API compartilham o contador) — requisito para rodar a API stateless com `--scale api=N`. - novo modulo `throttle.rs`: LoginThrottle (Redis ConnectionManager) com fallback automatico em memoria quando REDIS_URL ausente/indisponivel (fail-open; nginx ja faz rate-limit por IP na borda) - janela fixa via INCR+EXPIRE (login_fail:<ip>); is_blocked/record_failure/clear - AppState: login_attempts(DashMap) -> login_throttle; main.rs conecta o Redis best-effort no startup - remove `middleware/rate_limiter.rs` (PerKeyRateLimiter morto — nunca era declarado no mod tree nem usado; o limiter real por API key vive no api-public) Verificacao local: cargo build OK; clippy -D warnings limpo; testes do throttle (memoria + Redis local) passam (2/2). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AcsaeS7c9zJ4vkNtxqBcnc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TKT-017 — Rate limiter (login) → Redis
Torna o throttle de brute-force de login distribuído (Redis), para a API rodar stateless com
docker compose up --scale api=Nsem cada réplica multiplicar o limite.Mudanças
throttle.rs:LoginThrottlesobreredis::aio::ConnectionManager, com fallback automático em memória quandoREDIS_URLestá ausente/indisponível (fail-open — o nginx já faz rate-limit por IP na borda)INCR+EXPIRE(login_fail:<ip>); APIis_blocked/record_failure/clearAppState:login_attempts (DashMap)→login_throttle;main.rsconecta o Redis best-effort no startupmiddleware/rate_limiter.rs—PerKeyRateLimitermorto (nunca declarado no mod tree nem usado; o limiter real por API key vive noapi-public, será migrado para Redis no Sprint 5 quando montado noapi)Verificação local
cargo build -p api✓cargo clippy -p api -- -D warnings✓ (limpo)cargo test -p api throttle✓ 2/2 — memória e Redis (contra Redis local)🤖 Generated with Claude Code
Generated by Claude Code