Tech Story
As a platform engineer, I want rate limiting applied to authentication endpoints so that brute force and credential stuffing attacks are blocked before they can enumerate valid credentials or exhaust server resources.
Context
POST /auth/login, POST /auth/register, and POST /auth/forgot-password are completely unprotected against automated abuse. An attacker can make unlimited requests to enumerate usernames, brute force passwords, or spam password reset emails. @nestjs/throttler is not currently installed.
Acceptance Criteria
Technical Elaboration
- Install
@nestjs/throttler
- Register
ThrottlerModule.forRootAsync in AppModule reading limits from ConfigService
- Apply
ThrottlerGuard as a global guard via APP_GUARD
- Use
@Throttle() decorator on specific auth controller methods to override the global default
- Throttle by IP using the default
ThrottlerGuard; for production behind a proxy, configure skipIf or trusted proxy header forwarding so X-Forwarded-For is used as the key
- Add env vars:
THROTTLE_TTL, THROTTLE_LIMIT, AUTH_THROTTLE_TTL, AUTH_THROTTLE_LIMIT (with sensible defaults)
Notes
- If the app runs behind an nginx/k8s ingress that already rate-limits, this provides defence-in-depth at the application layer
@SkipThrottle() should be applied to health check endpoints if added later
Tech Story
As a platform engineer, I want rate limiting applied to authentication endpoints so that brute force and credential stuffing attacks are blocked before they can enumerate valid credentials or exhaust server resources.
Context
POST /auth/login,POST /auth/register, andPOST /auth/forgot-passwordare completely unprotected against automated abuse. An attacker can make unlimited requests to enumerate usernames, brute force passwords, or spam password reset emails.@nestjs/throttleris not currently installed.Acceptance Criteria
ThrottlerModuleinstalled and registered globally inAppModulePOST /auth/login: max 10 requests per minute per IPPOST /auth/register: max 5 requests per minute per IPPOST /auth/forgot-password: max 5 requests per minute per IP429 Too Many Requestswith aRetry-AfterheaderTechnical Elaboration
@nestjs/throttlerThrottlerModule.forRootAsyncinAppModulereading limits fromConfigServiceThrottlerGuardas a global guard viaAPP_GUARD@Throttle()decorator on specific auth controller methods to override the global defaultThrottlerGuard; for production behind a proxy, configureskipIfor trusted proxy header forwarding soX-Forwarded-Foris used as the keyTHROTTLE_TTL,THROTTLE_LIMIT,AUTH_THROTTLE_TTL,AUTH_THROTTLE_LIMIT(with sensible defaults)Notes
@SkipThrottle()should be applied to health check endpoints if added later