Description
To protect against authentication brute-force attacks and automated settlement spam, dedicated rate limits need to be applied to sensitive authentication and transaction submission routes using @fastify/rate-limit.
Context & Requirements
- Fastify rate limit plugin (
@fastify/rate-limit) is installed in dependencies.
- Global defaults should remain, but strict rate limits must be configured for high-risk endpoints:
- SEP-10 challenge generation (
POST /auth/challenge): max 10 requests per minute per IP.
- SEP-10 token exchange (
POST /auth/token): max 10 requests per minute per IP.
- Settlement transaction submission (
POST /settlements/submit): max 20 requests per minute per user/IP.
Acceptance Criteria
Implementation Guidance
- Register and configure route-specific limits using Fastify plugin route config objects.
- Keep rate limit definitions clear and configurable via environment settings if applicable.
- Ensure test suite disables or handles rate limiters properly during integration test execution.
Testing & Validation
- Run
npm test and npm run test:integration to ensure standard tests pass.
- Add an integration test in
tests/rateLimit.test.ts firing rapid requests to verify 429 response behavior.
Submission Guidelines
- Open a PR that includes "Closes #".
- Ensure task assignment before work commences.
- Run
npm run lint before submitting.
Wave complexity: Medium
Description
To protect against authentication brute-force attacks and automated settlement spam, dedicated rate limits need to be applied to sensitive authentication and transaction submission routes using
@fastify/rate-limit.Context & Requirements
@fastify/rate-limit) is installed in dependencies.POST /auth/challenge): max 10 requests per minute per IP.POST /auth/token): max 10 requests per minute per IP.POST /settlements/submit): max 20 requests per minute per user/IP.Acceptance Criteria
config.rateLimitroute options on target endpoint handlers insrc/routes/auth.tsandsrc/routes/settlements.ts.x-ratelimit-limit,x-ratelimit-remaining,x-ratelimit-reset) are returned in HTTP responses.Implementation Guidance
Testing & Validation
npm testandnpm run test:integrationto ensure standard tests pass.tests/rateLimit.test.tsfiring rapid requests to verify 429 response behavior.Submission Guidelines
npm run lintbefore submitting.Wave complexity: Medium