Skip to content

Rate Limits

The auth service enforces rate limits on all sensitive endpoints using KV-backed sliding window counters. Rate limits fail closed — if KV is unavailable, the request is denied.

EndpointLimitWindowKey
Password login5 attempts15 minIP + project
PIN login5 attempts15 minIP + project
Signup3 attempts1 hourIP
Magic link send3 sends1 hourEmail
Token exchange20 requests60 secclient_id
OIDC token20 requests60 secclient_id

Unlike many rate limiters that fail open (allow on error), the auth service denies requests when KV is unavailable. This prevents brute-force attacks during infrastructure issues.

Login rate limits are scoped to IP + project. Being rate-limited on proj_gym doesn’t affect authentication attempts on proj_bot.

There is no API key or header to bypass rate limits. Admin endpoints are also rate-limited (via the token exchange limit on proj_admin).

Admins can reset rate limit counters for a project via the admin API:

Terminal window
curl -X POST https://auth.beshoy.ai/admin/projects/proj_gym/rate-limits/reset \
-H "Authorization: Bearer $ADMIN_TOKEN"

This clears all KV counters for the project — useful after a legitimate user gets locked out.

async function fetchWithRetry(url: string, options: RequestInit, maxRetries = 3) {
let delay = 1000;
for (let i = 0; i <= maxRetries; i++) {
const res = await fetch(url, options);
if (res.status !== 429) return res;
if (i < maxRetries) {
await new Promise((r) => setTimeout(r, delay));
delay = Math.min(delay * 2, 60000);
}
}
throw new Error('Rate limited after retries');
}