# Sign-in options

URL: https://lyeve.com/docs/integrations/oauth-sso/

> **Requires** a license with the `saml`, `scim` or `device-fingerprint` feature for those options. Passwords, magic links, OAuth sign-in, MFA and captcha are free, and OAuth sign-in and MFA have paid parts named in the tables. See [pricing](https://lyeve.com/pricing/).

Every way of signing in ends the same way: the person holds a LyEve session
token, the same one a password sign-in gets, and your services verify it the
same way (see [validate tokens](https://lyeve.com/docs/integrations/validate-tokens-jwks/)). What differs is who
checks the person's identity, and what extra checks stand in front of it. Most
instances combine several options: a way in, a second factor, and something
that slows down attackers.

## Ways in

| Option | Best for | Free or license | Page |
|---|---|---|---|
| Password | Every instance. The first super admin always signs in this way. | Free | [Quickstart](https://lyeve.com/docs/getting-started/quickstart/), and [password reset](https://lyeve.com/docs/features/password-reset/) for a forgotten one |
| Magic link | Occasional editors who would rather click an emailed link than keep a password. | Free | [Magic link sign-in](https://lyeve.com/docs/features/magic-link-sign-in/) |
| OAuth and OpenID Connect | Teams on Google Workspace, Okta, Azure AD, Keycloak or any OIDC provider. | Free with one provider. More providers, the Okta and Azure AD templates and role mapping need `oauth-pro` | [OAuth sign-in](https://lyeve.com/docs/features/oauth-sign-in/) |
| SAML | Companies whose identity provider speaks SAML 2.0, with a provider per tenant. | Requires `saml` | [SAML single sign-on](https://lyeve.com/docs/features/saml-sso/) |

## Accounts from your directory

| Option | Best for | Free or license | Page |
|---|---|---|---|
| SCIM provisioning | Creating, updating and removing accounts from Azure AD, Okta or another directory before anyone signs in. Pair it with SAML. | Requires `scim` | [SCIM provisioning](https://lyeve.com/docs/features/scim-provisioning/) |

## Accounts a tenant's provider creates

An account that SAML, OAuth or SCIM creates, or that a magic link sign-up
creates, belongs to the tenant it was created in. LyEve finds it by that tenant
and its address. On an install with several tenants, the same address can be
a different account in each tenant, and a sign-up, password reset or magic link
answers the same whether another tenant holds the address or nobody does. An
account that signs in with a password under its own address works as before.
LyEve Console's user list marks these accounts **Signs in through your identity
provider**.

Because an address can repeat across tenants, a session's `email` claim does
not identify an account on its own. Identify an account by its id, the `sub`
claim. See [validate tokens](https://lyeve.com/docs/integrations/validate-tokens-jwks/#what-a-token-holds).

### Name the organization

Password sign-in, password reset and magic link take an optional `tenant`
field in the request body. The tenant the request's hostname resolves always
wins over it, so the field counts only where the hostname names no tenant. The
console's sign-in, forgot password and email link pages show it as
**Organization (optional)** when the console runs with
`SIGN_IN_ORGANIZATION=true`. A reset link carries the account's tenant. With
the switch on, the sign-in page it leads to fills the field in. With it off,
the console sends no tenant, so only the hostname can name one.

### Sign-in without the provider

An account a provider signs in can also sign in with a password, reset its
password or ask for a magic link. Each tenant decides how many days after the
account's last sign-in through its provider those ways stay open. After that,
they answer as they do for an unknown address or a wrong password.

| Setting | Values | Default |
|---|---|---|
| Days since the last provider sign-in | `0` to `365`. `0` allows sign-in through the provider only. | `30` |

Removing someone at your provider tells LyEve nothing, so the other ways close
when the window passes. To close them at once, provision with
[SCIM](https://lyeve.com/docs/features/scim-provisioning/). A person the directory deactivates
is refused at SAML sign-in, password reset and magic link from that moment,
whatever the window says. An account that a magic link sign-up created has no
provider, so the window does not apply to it.

A tenant admin sets the window:

<div class="paths">
<div data-path="console">

Open **Settings > Sign-in**. Under **Without the identity provider**, enter
the number in **Days since the last provider sign-in** and choose **Save**.

</div>
<div data-path="api">

```bash
curl -X PUT http://localhost:3001/api/admin/auth/provider-window \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"days": 7}'
```

```json
{ "days": 7 }
```

</div>
</div>

`GET /api/admin/auth/provider-window` answers the same shape. Both routes need
the `admin` or `super_admin` role and a signed-in session. An API key or an
admin token is refused with `403`. An admin acts on their own tenant, and a
super admin on the tenant named with `X-Tenant-ID`. A value that is not a whole
number from 0 to 365 answers `422`. A change applies to the next sign-in, and
each one is written to the [audit log](https://lyeve.com/docs/features/audit-log/) as
`auth.provider_window.update` with the old and new values.

When you upgrade to 0.55.0, accounts that OAuth created and accounts that an
active SCIM user links count as signed in through their provider at the
upgrade, so they keep their other ways in for one window. An account that
SAML created without SCIM starts its window at its next SAML sign-in. No
window applies to it until then, so its password, password reset and magic
link stay open.

## Extra checks at sign-in

| Option | Best for | Free or license | Page |
|---|---|---|---|
| Multi-factor auth and passkeys | A second step after the password, or a passkey with no password at all. | Free. Enrolling a passkey needs `mfa-pro` | [Multi-factor authentication](https://lyeve.com/docs/features/multi-factor-auth/) |
| Trusted devices | Asking for the second factor only when a sign-in looks risky, and blocking brute force on every sign-in route. | Requires `device-fingerprint` | [Trusted devices](https://lyeve.com/docs/features/trusted-devices/) |
| Captcha | A challenge after a few failed password sign-ins. | Free | [Captcha](https://lyeve.com/docs/features/captcha/) |

Every install also allows 5 password sign-in attempts per address every 15
minutes, and refuses an account's password sign-in after 5 failures within 15
minutes. See [rate limiting](https://lyeve.com/docs/features/rate-limiting/).

## Choose

- **A small team with no identity provider:** passwords, with
  [MFA](https://lyeve.com/docs/features/multi-factor-auth/) for admins and
  [captcha](https://lyeve.com/docs/features/captcha/) on.
- **A team that already lives in Google Workspace, Okta or Azure AD:**
  [OAuth sign-in](https://lyeve.com/docs/features/oauth-sign-in/), and keep one password super
  admin for when the provider is down. The Okta and Azure AD templates need
  `oauth-pro`.
- **An enterprise customer with a SAML directory:** [SAML](https://lyeve.com/docs/features/saml-sso/)
  for sign-in and [SCIM](https://lyeve.com/docs/features/scim-provisioning/) for accounts.
- **Editors who sign in once a month:** [magic links](https://lyeve.com/docs/features/magic-link-sign-in/).

Programs do not sign in. A site or app uses an
[API key](https://lyeve.com/docs/features/api-keys/), and a script on the Admin API uses an
[admin token](https://lyeve.com/docs/how-to/admin-tokens/). See
[which credential do I need](https://lyeve.com/docs/guides/user/roles-and-permissions/#which-credential-do-i-need).
