# Authentication settings

Set per project in the console: open the project, then **Sign-in**. Owners and developers can change them; read-only members can look.

## URL configuration

- **Site URL**: where your application lives. One exact address. Sign-in sends people here when no other address is asked for, the links in emails lead here, and pages at this address may call the API from a browser.
- **Redirect URLs**: other addresses sign-in may send people back to, and whose pages may call the API.

Anything not listed is refused before a person is sent anywhere.

| Pattern | Matches |
|---|---|
| `https://app.example.com/signed-in` | Exactly that address |
| `https://*.example.com` | `*` stands for the first part of a host |
| `https://app.example.com/*/done` | `*` stands for one part of a path |
| `https://app.example.com/auth/**` | `**` at the end of a path means anything below it |
| `myapp://sign-in` | An app's own scheme, written out in full |
| `http://localhost:3000` | Plain `http` is accepted only for `localhost` |

### Calling the API from a browser

The same list decides which web pages may call the API. The API answers cross-origin requests only for origins on the project's list, never with a wildcard and never with credentials. The headers a page may send are `apikey`, `authorization`, `content-type` and `x-organization-id`.

If a browser reports a CORS error, the page's address is not on the project's list.

## Sign-in methods

| Method | New project | Notes |
|---|---|---|
| Email and password | On | Can be switched off |
| Self sign-up | Off | When on, new accounts join the organization the project names |
| New accounts must confirm their email address first | Off | See [Email flows](https://rezincore.com/docs/auth/email-flows.md#confirm-sign-up) |
| Sign-in link by email | Off | See [Email flows](https://rezincore.com/docs/auth/email-flows.md#sign-in-link-or-code) |
| Google | Off | See [Google and GitHub](https://rezincore.com/docs/auth/providers.md) |
| GitHub | Off | See [Google and GitHub](https://rezincore.com/docs/auth/providers.md) |

Self sign-up needs an organization for new accounts to join. A new project already names its first one.

## Sessions and limits

A project may be stricter than the platform, never looser.

| Setting | Platform limit | Meaning |
|---|---|---|
| Idle sign-out | up to 15 minutes | A token stops working after this long without use |
| Longest sign-in | up to 12 hours | A token stops working this long after sign-in, whatever happens |
| Sign-in attempts per network address per minute | default 10 | Shared by sign-up, sign-in, provider sign-in and code exchange |

These protect every project and cannot be loosened per project:

- 5 wrong passwords or codes in a row lock an account for 15 minutes.
- Passwords are 12 characters or more.
- Each key may send 600 requests a minute, and each network address 300 a minute whatever key it uses.

## Passwords, one sign-in at a time, and the authenticator step

Sign-in, **Sessions and limits**.

- **Authenticator app**: *Nobody* (it cannot be set up), *Each person decides* (the default), or *Everyone must*. With *Everyone must*, an account that has not set one up can sign in but is answered `403 second_step_required` by the data, storage and function routes until it has; the set-up calls still work, so your application shows the set-up screen when it gets that answer. See [Authenticator app](https://rezincore.com/docs/auth/authenticator.md).
- **Refuse passwords people choose most often.** Checked when a password is chosen (sign-up, change, reset, invitation), against a list kept on Rezin Core's own servers. Also refuses the same few characters repeated and a run of digits in order. The answer is `400 weak_password`. A password is never sent anywhere to be checked.
- **One sign-in at a time for each account.** Signing in somewhere new ends that account's sign-in everywhere else.

## The sign-in record

Sign-in, **Sign-in record**. What has happened at your application's front door: sign-ins and sign-outs, new accounts, password changes and resets, the authenticator step, addresses held back for too many attempts, and what members did to accounts from the console. The newest 200, filtered by kind, by result, or by a name, email or network address. Above it, the last fourteen days: how many signed in, how many were turned away, how many accounts were made.

It holds events only: who, what, when, from where and by which method. Never a password, a code or a link. A read-only member can read it.

## Organizations

The **Sign-in** page lists the project's organizations and lets you add one. See [Concepts](https://rezincore.com/docs/getting-started/concepts.md#organizations).

## Accounts

Sign-in, then Accounts: the people who can sign in to your application. See [Managing accounts in the console](https://rezincore.com/docs/auth/overview.md#managing-accounts-in-the-console).

## The second step and emails

- Any user can have an authenticator app as a second step. See [Authenticator app](https://rezincore.com/docs/auth/authenticator.md).
- The emails the project can send are listed with previews on the project's **Emails** page. See [Email](https://rezincore.com/docs/email.md).
