backend/horizon-api/lib/common/rate-limit/auth-rate-limit.config.ts) and from the
authenticate/security-hardening initiative.
How the limiter works
The limiter uses a shared counter in Upstash. Its mode is the server flagauthenticate-rate-limit-mode of horizon-api, edited in Horizon Enterprise → Capabilities (it needs
feature-flag:update-security). It replaced AUTH_RATE_LIMIT_ENFORCE in 2026.11.2; the variable is
read only as a transitional fallback until 2026.11.3.
Every environment runs
shadow from the 2026.11.2 release night and moves to enforce after 7 days
of logs. If the flag store cannot be read, the limiter enforces (safe default).
Policies marked always are enforced whatever that value says. Policies marked silent answer
the same as a successful request once over budget, so nothing is revealed. When Upstash does not
respond, each policy decides: local uses a per-instance counter and closed answers 503.
IPs are stored as a hash with a daily salt. The user key is the hash of the presented bearer, so a
refreshed token starts with a new budget.
Limits per route
apple-notifications is counted after the JWS is verified, keyed by apple: plus the subject,
because every event comes from Apple’s shared egress.
Lockout after failed attempts
With the server flagauthenticate-login-lockout on (formerly AUTH_LOCKOUT_ENABLED), each account (identified by an HMAC of its e-mail) allows 5 failed
password attempts in 15 minutes. The sixth attempt inside the window answers 423 and the account
stays locked for 15 minutes. A successful sign-in clears the counter, and password recovery resets it
too. The counter lives in Upstash; without Upstash it counts per instance.
Support can unlock an account with:
auth:unlock-lockout permission. It answers 503 when the lock could not be
deleted, so support does not report an unlock that did not happen.
Pending. The lockout is turned on once the client copy has shipped. The production target is to
have both the limiter and the lockout enforced.
End-user IP forwarding
horizon-authenticate callsverify-email, magic-link/request, password sign-in and recovery from
server actions. All those calls leave from the same server IP. So that the per-IP limit counts each
person and not the server (ADR 0098):
- horizon-authenticate reads the user’s IP (
x-vercel-forwarded-for,x-real-ip) and sends it inx-auth-client-ip, together withx-auth-bff-token. - horizon-api uses that IP only when
x-auth-bff-tokenmatches itsAUTH_BFF_SERVER_TOKEN.
AUTH_BFF_SERVER_TOKEN must hold the same value (at least 32 characters) in
horizon-api and in horizon-authenticate of each environment. portal-customer already uses it.
Keyrings
They are different keyrings and are never mixed. Without
AUTH_PROVIDER_TOKEN_KEYRING, Apple refresh
tokens are not stored and cannot be revoked when the account is deleted. The steps are in
Operations and maintenance.
Callback hardening
- Tokens in the fragment. Deep links carry the tokens after
#, never in the query. - 410 for query tokens. A
GETtocallback-redirectwith tokens in the query answers410 OAUTH_CALLBACK_UPGRADE_REQUIRED: always for Microsoft, and for the others when theauthenticate-oauth-query-tokens-acceptedflag isfalse. Usage is logged asoauth_query_tokens_used. - Provider identity. Each callback accepts only a session that holds its provider’s identity
(Google
google, Microsoftazure);app_metadata.providerdoes not count. - Unverified e-mail. Without an e-mail, or with an unverified one, no profile is created: the deep
link returns
error=unverified_email. For Microsoft the e-mail only counts as verified throughemail_confirmed_ator the Azure identity of the same address. - Redirect allowlist.
redirect_urlis checked againstconfig/social-login/redirects.<environment>.json. With thesecurity-social-redirect-enforceflagfalseit is only logged; the flag istruein every environment right after the 2026.11.2 Sync (T-105). - No caching. Session-bearing responses send
cache-control: no-storeandpragma: no-cache.
Accepted risks
Enumeration (ADR 0134).
verify-email returns providers, so it reveals which enabled provider
an e-mail uses. This is accepted because the route is rate-limited and returns no profile data. A
mail scanner that runs JavaScript can burn a magic link; that is accepted too.Open tasks
As of 2026-11-04 theauthenticate/security-hardening initiative stands at 8%. The most relevant: