WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Variable authRateLimiterConst

    authRateLimiter: RateLimitRequestHandler = ...

    Authentication Rate Limiter for Security-Critical Endpoints

    Strict rate limiter specifically designed for authentication endpoints to prevent brute force attacks, credential stuffing, and account enumeration attempts. This limiter has much lower thresholds than the default limiter and is applied to login, registration, and password reset endpoints.

    The restrictive limits help protect user accounts while still allowing legitimate authentication attempts. Failed authentication attempts are logged for security monitoring and potential account lockout mechanisms.

    Strict rate limiting middleware for auth endpoints

    // Usage in authentication routes
    import { authRateLimiter } from '@/shared/middleware/security';

    router.post('/login', authRateLimiter, loginController);
    router.post('/register', authRateLimiter, registerController);
    router.post('/forgot-password', authRateLimiter, forgotPasswordController);
    // Environment variable configuration
    // .env file
    AUTH_RATE_LIMIT_WINDOW_MS=900000 # 15 minutes
    AUTH_RATE_LIMIT_MAX_REQUESTS=5 # 5 attempts per window