feat: share rate-limit counters across API instances
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- express, postgresql, typescript
Direção de pesquisa
Start with docs/production-operations.md and inspect the account notice limiters, flow_rate_limits, and the global per-IP limiter to understand how counters are stored and applied. The issue leaves the store, limiter scope, and failure behavior open, so first map those choices into a design note or ADR. Done means the design is recorded, limits are verified across multiple instances by a test, and the operations documentation is updated.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Why
Every rate limiter and slow-down in the API uses the in-memory store of express-rate-limit or express-slow-down. Each instance counts on its own, so with N instances behind a load balancer a client whose requests spread across them gets up to N times each budget. docs/production-operations.md ("Running More Than One Instance") documents this and the workaround: route by client address, or limit at the proxy as well.
Routing by address does not help the account notice limits on POST /applications/account-notices, because they are keyed by application and user. An application can send up to N times its notice allowance however requests are routed.
The counters that bound guessing are already shared in Postgres (auth_failures, OTP codes, magic links, WebAuthn challenges, refresh rotation, the OAuth state record), so the gap is volume (OTP and magic link sends, notice spam, load), not account takeover. Split from #553, whose per-user key fix shipped in #567.
What
Decide and build a shared store for the limiters where per-instance counting matters:
- Which limiters share. The account notice limiters and
flow_rate_limitsfirst. Whether the global per-IP limit and slow-down need it, or stay in memory to keep the hot path free of a database write. - Which store. Postgres needs no new service, since every deployment has it already. A Redis or Valkey store could be an option for large deployments, never a requirement.
- Failure mode when the store is unreachable: fail open, fail closed, or fall back to memory, per limiter.
- Window and cleanup for expired counters.
Related
The global per-IP limit counts the provider edge's /oidc/* calls against the browser's address. Look at it in the same design.
Done when
- A design note or ADR records which limiters share, the store, and the failure mode
- Shared limits hold across two or more instances, covered by a test that runs more than one
-
docs/production-operations.mdis updated
- Linguagem predominante
- TypeScript
- Estrelas
- 2
- Forks
- 2
- Merge médio
- 12h 23min
- PRs com merge (30d)
- 109
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de fells-code/seamless-auth-api
-
P1 v0.23
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
fells-code/seamless-auth-api#586 ·
Mantenedores costumam responder em até 1 dia
-
easy P2 v0.23
Dificuldade 4/5 Mais de uma semana Facilidade para iniciantes 8/100
fells-code/seamless-auth-api#561 ·
Mantenedores costumam responder em até 1 dia
-
epic P1 security v0.23
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 8/100
fells-code/seamless-auth-api#558 ·
Mantenedores costumam responder em até 1 dia
-
epic P2 v0.23
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 5/100
fells-code/seamless-auth-api#551 ·
Mantenedores costumam responder em até 1 dia
-
P2 secure v2.1
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
fells-code/seamless-auth-api#512 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de fells-code/seamless-auth-api
Issues semelhantes
-
reproduced
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 61/100
anomalyco/opencode#62873 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
code-quality good-first-issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
OpenRailAssociation/netzgrafik-editor-frontend#1481 ·
Mantenedores costumam responder em até 1 dia
-
🙌 icon request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
lucide-icons/lucide#5183 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 81/100
cloudflare/capnweb#293 ·
Mantenedores costumam responder em até 2 dias
-
bug implicit-state
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100