# Authentication settings reference
Source: https://sovaria.in/docs/auth-settings

Every setting under Authentication: URL configuration, sessions, rate limits, multi-factor, passkeys, attack protection and custom JWT claims — what each does, defaults and plans.

These pages decide how your **app users** sign in and stay signed in. They don’t affect your team’s console accounts.

## URL configuration

**Site URL** is your app’s address; email links open it with `?token=…&type=…` when no allowed redirect is given. **Redirect URLs** are the other addresses sign-in may return to — `https://*.example.com/auth/**` patterns and app schemes like `myapp://callback`. Mobile apps register exact redirects under [Mobile apps](https://sovaria.in/docs/mobile-overview).

## Sessions

| Setting | What it does | Typical value |
|---|---|---|
| Refresh token reuse interval | A refresh token used again within this window returns the same new session (two tabs refreshing at once). After it, reuse is treated as theft and signs the user out everywhere. | 10 seconds |
| Single session per user | Signing in ends the user’s other sessions; only the newest device stays signed in. | Off, except banking-style apps |
| Time-box user sessions | Sign users out this long after they signed in, however active. 0 = never. | 0, or 12 hours for admin apps |
| Inactivity timeout | Sign users out when the app hasn’t refreshed the session for this long. 0 = never. | 0, or 30 minutes for shared computers |

|  | Free | Pro | Ultra | Team | Enterprise |
|---|---|---|---|---|---|
| Session time-box, inactivity timeout and single session | ✓ | ✓ | ✓ | ✓ | ✓ |

## Rate limits

Over a limit, requests get `429 AUTH_RATE_LIMITED` with `Retry-After`. Raise a limit only for a real reason (a classroom on one school IP); attackers rely on generous ones.

Codes and links (magic links with their email code, password resets, SMS codes) are also counted per address or number and per IP **in this project**, so another app never uses up your users' allowance. Over one of these, the request gets `429 OTP_RATE_LIMITED` with `Retry-After` and `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`, and nothing is sent. A refused request doesn't count. One IP may be sent SMS codes for up to 3× the per-number limit an hour across numbers.

Before your own limits, Sovaria caps sign-in, sign-up and reset requests per IP address for each project (10 a minute by default), with a higher ceiling for one address across all projects. Another app's traffic from the same network never uses up your users' allowance. Over it, requests get `429 AUTH_RATE_LIMIT_EXCEEDED` with `Retry-After`.

| Limit | Counts | Unit |
|---|---|---|
| Emails sent | Confirmations, magic links, resets and email changes for the whole project. | per hour |
| SMS sent | One-time codes by text for the whole project. | per hour |
| Sign-ups and sign-ins | Password and OTP sign-ins and sign-ups. | per 5 min, per IP |
| Token refreshes | Session refreshes. | per 5 min, per IP |
| Token verifications | OTP and magic-link checks. | per 5 min, per IP |
| Anonymous sign-ins | New anonymous users. | per hour, per IP |
| Failed sign-ins per account | Wrong passwords for one account from one address before that address is paused for 15 minutes. From all addresses together the account pauses at 5× this (at least 50), so one person typing wrong passwords for someone else's e-mail can't lock them out. | per 15 min, per account and address |
| Magic links | Per address and per IP, in this project (`OTP_RATE_LIMITED`). | per hour |
| Password resets | Per address and per IP, in this project (`OTP_RATE_LIMITED`). | per hour |
| Email code attempts | Wrong guesses at a 6-digit code before it and its link stop working. | per code |
| SMS codes per number | Codes one phone number can be sent; one IP gets 3× this across numbers (`OTP_RATE_LIMITED`). | per hour, per number |

## Multi-factor

Turn on **Authenticator app (TOTP)** and/or **Phone (SMS code)** and set **Maximum factors per user**. Users get backup codes when they enrol an authenticator. Turning a factor off stops new enrolments; users who have it can still use it. Require MFA for everyone under Sign in / Providers › Security (users without a factor get a session that can only set one up). **Security keys (WebAuthn)** adds FIDO2 keys and device authenticators as a second factor (plan key `auth.hardware_mfa`; uses the domain and origins under Auth › Passkeys).

### SMS provider and countries

Under Sign in / Providers › Phone pick **Twilio**, **MSG91** (India: your DLT flow template id and the variable that carries the code), **Vonage**, **MessageBird** or a Twilio-compatible API, with your own account (the secret is encrypted and never shown again; changing the provider clears it). For providers that take free text, set the message with `{{ code }}` and `{{ app_name }}`. **Countries** limits where texts go: allowed calling codes (blank = any) and blocked ones (for example `+882`, `+881`); a text elsewhere is refused with `422 SMS_COUNTRY_NOT_ALLOWED` before anything is sent. CAPTCHA, when on, also guards SMS codes and anonymous sign-ins. Turning the **Phone OTP** provider off stops SMS sign-in on every route.

### Anonymous users

Under Attack protection › Anonymous users: delete anonymous users who never became permanent after N days (30 by default; 0 keeps them), and the share of a hard monthly-active-user limit anonymous users may take (50 % by default).

|  | Free | Pro | Ultra | Team | Enterprise |
|---|---|---|---|---|---|
| Multi-factor authentication for app users | ✓ | ✓ | ✓ | ✓ | ✓ |
| Hardware-key MFA | ✓ | ✓ | ✓ | ✓ | ✓ |

## Passkeys

| Setting | Meaning |
|---|---|
| Enable passkeys | Users can register a passkey after signing in, then sign in with it. A passkey sign-in counts as multi-factor. |
| Relying party ID | Your domain, e.g. `example.com`. Passkeys work on it and its subdomains and can’t move to another domain later. |
| Display name | Shown by the browser when users create a passkey. |
| Allowed origins | Every address your sign-in page runs on (scheme, host and port). |

## Attack protection

- **Leaked password protection** rejects passwords found in known breaches (Have I Been Pwned). Only the first 5 characters of the password’s SHA-1 hash leave Sovaria (k-anonymity).
- **Hide whether an account exists** is always on: sign-in, magic link, password reset and OTP requests answer the same way whether or not the address has an account, so attackers can’t learn who uses your app. Sign-up still says when an address is already registered.
- **CAPTCHA** on sign-up, sign-in and reset (Sign in / Providers › Security).

|  | Free | Pro | Ultra | Team | Enterprise |
|---|---|---|---|---|---|
| Leaked password protection | ✓ | ✓ | ✓ | ✓ | ✓ |

## Custom JWT claims

Register an HTTPS hook Sovaria calls on every token issue. The request is signed (`X-Sovaria-Signature`) and carries the user id, project context and base claims; the hook answers with extra keys that are merged into the token’s `ctx`, so your app and functions can read them from the session. Keys Sovaria owns (`roles`, `org_id`, `project_id`…) are ignored, and a hook slower than 50 ms is skipped so sign-in never waits — stock claims are used instead. If your plan stops including custom claims, tokens go back to stock claims.

Hook response:
```json
{ "claims": { "plan_tier": "gold", "team_ids": ["t_12", "t_40"] } }
```

|  | Free | Pro | Ultra | Team | Enterprise |
|---|---|---|---|---|---|
| Custom JWT claims | ✓ | ✓ | ✓ | ✓ | ✓ |
