# Single sign-on

Source: https://docs.savorum.app/admin/single-sign-on/

> Let people sign in with an existing sign-in service, through OpenID Connect, LDAP or Active Directory, a trusted reverse proxy, or SAML 2.0.

If your household or organization already has a sign-in service, people can use it for Savorum instead of a separate password. Savorum supports OpenID Connect (OIDC), LDAP and Active Directory, a trusted reverse proxy, and SAML 2.0. Each person still gets a full Savorum account that owns their libraries and recipes.

## Before you start

- [Turn on sign-in and create an administrator](https://docs.savorum.app/admin/accounts/).
- Set an HTTPS public URL, or use an enabled [Connect address](https://docs.savorum.app/admin/connect/#sign-in-methods) for remote sign-in.
- Make sure you have a tested way back in as administrator, such as a password and the `user reset-password` command.

## Connect a provider

1. List your providers in a JSON file, using the examples below. Keep passwords, client secrets, and keys in separate files that it refers to, readable only by the Savorum service account.

2. Point Savorum at the file, with `--auth-providers-file` or `SAVORUM_AUTH_PROVIDERS_FILE`:

   ```sh
   savorum serve --database /var/lib/savorum/savorum.db \
     --auth-enabled --public-url https://recipes.example.com \
     --auth-providers-file /etc/savorum/providers.json
   ```

3. Restart Savorum whenever you change the file.

Every provider has an ID, such as `company-oidc`. Choose it once and keep it. Use a new ID when the sign-in service itself changes, and never reuse an old ID for a different organization. `local`, `passkey`, `recovery`, `token`, and `system` are reserved.

Every provider also accepts:

- `auto_provision`: creates an account the first time someone new signs in. Off by default. Accounts are never merged because their emails match.
- `default_library` and `default_role` (`viewer` or `editor`): give new accounts a starting membership.
- `allow_local_recovery: true`: lets people who sign in only through this provider create recovery codes. Off by default.

Without automatic accounts, a person needs an [invitation](https://docs.savorum.app/admin/accounts/#invite-people), or must link the provider to their existing account under **Your account → Sign-in and security**.

- OpenID Connect
- LDAP / Active Directory
- Trusted proxy
- SAML 2.0

## OpenID Connect

```json
{
  "providers": [
    {
      "id": "company-oidc",
      "kind": "oidc",
      "display_name": "Company account",
      "auto_provision": true,
      "default_library": "YOUR_LIBRARY_ID",
      "default_role": "viewer",
      "oidc": {
        "issuer": "https://identity.example.com/realms/company",
        "client_id": "savorum",
        "client_secret_file": "/run/secrets/savorum-oidc-client",
        "groups_claim_path": "organization.groups"
      }
    }
  ]
}
```

Register this exact redirect URI with the provider:

```text
https://recipes.example.com/api/v1/auth/company-oidc/callback
```

For [Connect](https://docs.savorum.app/admin/connect/), also register this callback path at your assigned Connect address. Keep the local redirect URI if you use SSO locally.

Savorum asks for `openid profile email`, plus anything you list in `scopes`. Set `groups_claim_path`, a dot-separated path, only if the provider puts a trustworthy list of groups in its ID token. A missing claim means no groups. A malformed claim fails sign-in.

## Grant library roles from groups

OIDC, LDAP, and SAML providers can pass a person’s groups to Savorum. To turn a group into a library role:

1. Open **Instance administration → Sign-in providers**.
2. Choose the provider and enter the group exactly as the provider sends it.
3. Choose a library and a role.

Each rule grants one membership. The same group name from a different provider grants nothing. When a group disappears, only that rule’s membership goes. Manual memberships and other rules stay, and the highest role applies.

**Removing someone from a group doesn’t end their access until they sign in again.** To remove someone at once, disable their Savorum account or revoke their sessions.

## Test before you rely on it

Sign in through the provider with an account that isn’t an administrator, and check that it gets only the library memberships you intended.

## Good to know

- Removing or disabling a provider takes effect at the next restart. It ends that provider’s browser sessions and removes the memberships it granted. Accounts, manually granted memberships, and other sign-in methods stay.
- Tokens created while signed in through a provider stop working when that provider is disabled.
