Rate limiting protects authentication endpoints from brute force attacks, credential stuffing, and email bombing. All limits are tenant-scoped (per-environment) with global safety nets to prevent cross-tenant abuse.
┌─────────────────────────────────────────────────────────────────┐
├─────────────────────────────────────────────────────────────────┤
│ 1. Preauth Middleware (500/min per IP) │
│ └─ Blocks random auth_flow_id hammering before DB access │
│ 2. Config/OAuth Rate Limits (token bucket) │
│ └─ Burst-friendly for enterprise login spikes │
│ 3. Verification Rate Limits (layered) │
│ ├─ Temporary lockout (10 failures → 30 min lock) │
│ ├─ Exponential backoff (3+ failures → increasing delays) │
│ ├─ Per-env per-email limit │
│ ├─ Per-env per-IP limit │
│ └─ Global email safety net │
│ ├─ Deduplication (3 min window) │
│ ├─ Per-env per-email hourly │
│ ├─ Per-env per-IP hourly │
│ └─ Global daily safety net │
└─────────────────────────────────────────────────────────────────┘
Tier Multiplier Use Case DEFAULT1x Standard limits for most customers ENTERPRISE5x Higher limits for enterprise customers CUSTOMConfigurable Per-limit overrides via rate_limit_overrides
Applied before any database access to block attackers hammering random auth flow IDs.
Limit Scope Purpose 500/min Per IP High threshold to block automated attacks
Limit Scope Purpose 120/min Per IP (token bucket) Burst-friendly for enterprise SSO 600/min Per environment Circuit breaker per tenant
Layer Limit Scope Trigger Temporary lockout 30 min lock Per env + email 10+ failures Exponential backoff 5s → 15 min Per env + email 3+ failures Rate limit 5/15min Per env + email Standard limit Rate limit 10/15min Per env + IP Standard limit Global safety net 20/15min Global per email Prevents tenant rotation
Layer Limit Scope Deduplication 3 min window Per env + email + type Hourly per address 3/hour Per env + email + type Hourly per IP 10/hour Per env + IP + type Daily global 20/day Global per email
All rate limits are configurable via environment variables.
Variable Default Description RATE_LIMIT_CONFIG_PER_IP120/minuteConfig endpoint per IP RATE_LIMIT_CONFIG_PER_ENV600/minuteConfig endpoint per environment RATE_LIMIT_VERIFY_PER_ENV_EMAIL5/15minutesPer env + email RATE_LIMIT_VERIFY_PER_ENV_IP10/15minutesPer env + IP RATE_LIMIT_EMAIL_PER_ENV_ADDR3/hourPer env + email + type RATE_LIMIT_EMAIL_GLOBAL_DAILY20/dayGlobal daily per email BACKOFF_BASE_SECONDS5Initial backoff delay BACKOFF_MAX_SECONDS900Maximum backoff (15 min) BACKOFF_LOCKOUT_THRESHOLD10Failures before lockout RATE_LIMIT_ENTERPRISE_MULTIPLIER5.0Multiplier for enterprise tier
HTTP / 1.1 429 Too Many Requests
"detail" : " Too many verification attempts. Please try again later. " ,
"code" : " rate_limit_exceeded "
HTTP / 1.1 429 Too Many Requests
"detail" : " Account temporarily locked due to too many failed attempts. " ,
"code" : " exceeded_max_login_attempts "
The Retry-After header indicates seconds until the limit resets.