---
title: "Set up single sign-on"
sidebarTitle: "Set up single sign-on"
description: "Prove control of your email domain, connect an OIDC or SAML identity provider, test it, then decide whether to require it."
keywords: ["SSO", "single sign-on", "OIDC", "SAML", "verified domain", "identity provider", "just-in-time provisioning", "group mapping"]
---

Single sign-on routes everyone at your email domain to your own identity
provider. Setting it up is four steps in a fixed order: verify a domain,
configure the provider, test a sign-in, and only then require it.

This is an **owner** action. Every write on this page needs `identity:manage`,
which only the `owner` role holds and which cannot be granted to an API key.
Admins can read the configuration and nothing more. Single sign-on is also a
plan feature (`sso`), and the plan is checked when you **save** a
configuration, never at sign-in, so a plan that lapses later does not lock
anyone out.

Everything below is under **Settings → Identity** in the dashboard. The API
calls are shown for each step because the same endpoints back the screen.

## 1. Verify your domain

A domain decides which sign-ins are routed to your provider and which
addresses your provider is allowed to assert. Nothing about a domain takes
effect until you have proved you control it.

<Steps>
  <Step title="Claim the domain">
    Under **Verified domains**, add the domain (ASCII only; an
    internationalized domain goes in as punycode).

    ```bash
    curl -s -X POST https://app.trustivan.com/api/v1/identity/domains \
      -H 'Content-Type: application/json' \
      -b cookies.txt \
      -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
      -d '{"domain": "acme.com"}'
    ```

    The response carries the claim, with its `verification_token`, and an
    `instructions` string naming the exact record to publish.
  </Step>
  <Step title="Publish the TXT record">
    Create a DNS `TXT` record **at the domain itself** whose value is
    `trustivan-domain-verification=` followed by the token. The dashboard shows
    the record name and value with copy buttons, and
    `GET /api/v1/identity/domains` returns the prefix as `txt_record_prefix`.
  </Step>
  <Step title="Verify">
    Select **Verify**, or call the endpoint. The domain shows `awaiting DNS`
    until the record is visible and `verified` afterwards.

    ```bash
    curl -s -X POST "https://app.trustivan.com/api/v1/identity/domains/$DOMAIN_ID/verify" \
      -b cookies.txt \
      -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')"
    ```

    A `400` means the record was not found or DNS could not be read; wait for
    propagation and try again. Verifying is idempotent.
  </Step>
</Steps>

<Note>
  Two organizations may claim the same domain, but only one can verify it. If
  another organization already has, verification answers `409` and never says
  who.
</Note>

## 2. Register TRUSTIVAN with your identity provider

Your provider needs to know where to send people back. Read the values from
your deployment instead of typing them from this page: the dashboard shows them
at the top of the **Single sign-on** card, and `GET /api/v1/identity/provider`
returns them even before anything is configured.

| Field in the response | Register it as | Path on your deployment |
|---|---|---|
| `redirect_uri` | OIDC redirect URI | `/api/v1/auth/sso/oidc/callback` |
| `acs_url` | SAML assertion consumer service URL | `/api/v1/auth/sso/saml/acs` |
| `entity_id` | SAML service provider entity ID | `/saml/metadata` |

## 3. Configure the provider

An organization has one provider, and it is either OIDC or SAML. Saving a
configuration builds the provider from it, so a configuration that saves is one
that can authenticate, and an incomplete one is refused with a `400` that names
the missing field.

<Tabs>
  <Tab title="OIDC">
    ```bash
    curl -s -X PUT https://app.trustivan.com/api/v1/identity/provider \
      -H 'Content-Type: application/json' \
      -b cookies.txt \
      -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
      -d '{
            "protocol": "oidc",
            "display_name": "Acme Okta",
            "config": {
              "issuer": "https://acme.okta.com",
              "client_id": "0oa1b2c3d4",
              "authorization_endpoint": "https://acme.okta.com/oauth2/v1/authorize",
              "token_endpoint": "https://acme.okta.com/oauth2/v1/token",
              "jwks_uri": "https://acme.okta.com/oauth2/v1/keys"
            },
            "client_secret": "…",
            "enabled": true,
            "jit_provisioning": true,
            "jit_default_role": "viewer"
          }'
    ```

    | `config` key | Required | Notes |
    |---|---|---|
    | `issuer` | Yes | Compared exactly against the `iss` claim of every ID token |
    | `client_id` | Yes | |
    | `authorization_endpoint` | Yes | |
    | `token_endpoint` | Yes | |
    | `jwks_uri` | Yes | |
    | `scopes` | No | A list of scope names |
    | `email_claim`, `name_claim`, `groups_claim`, `subject_claim` | No | Default to `email`, `name`, `groups` and `sub` |
    | `allowed_algorithms` | No | A list; empty means the built-in safe set |

    `client_secret` is its own field, not part of `config`. It is stored
    encrypted and no response ever returns it. Leave it out of a later `PUT` to
    keep the stored one, so changing the display name does not mean re-entering
    it.
  </Tab>
  <Tab title="SAML">
    ```bash
    curl -s -X PUT https://app.trustivan.com/api/v1/identity/provider \
      -H 'Content-Type: application/json' \
      -b cookies.txt \
      -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
      -d '{
            "protocol": "saml",
            "display_name": "Acme Entra ID",
            "config": {
              "entity_id": "https://sts.windows.net/1f0e…/",
              "sso_url": "https://login.microsoftonline.com/1f0e…/saml2",
              "certificates": ["-----BEGIN CERTIFICATE-----\n…\n-----END CERTIFICATE-----"]
            },
            "enabled": true,
            "jit_provisioning": true,
            "jit_default_role": "viewer"
          }'
    ```

    | `config` key | Required | Notes |
    |---|---|---|
    | `entity_id` | Yes | Your identity provider's entity ID |
    | `sso_url` | Yes | Where the sign-in request is sent |
    | `certificates` | Yes | One or more signing certificates |
    | `email_attribute`, `name_attribute`, `groups_attribute` | No | When unset, the common short names and the ADFS claim URIs are both tried |
    | `nameid_is_subject` | No | Default `true`. Set `false` when your provider emits a NameID that changes on every sign-in |
    | `subject_attribute` | No | The attribute carrying the stable identifier when `nameid_is_subject` is `false` |

    In the dashboard, **Import metadata** fills the entity ID, sign-in URL and
    certificate from your provider's metadata. Nothing is stored until you
    save.

    <Warning>
      Sign-in must start at TRUSTIVAN. An assertion that arrives without a
      sign-in request this deployment issued (identity-provider-initiated
      sign-on) is refused.
    </Warning>
  </Tab>
</Tabs>

Every endpoint must be `https`. Three fields apply to both protocols:

| Field | What it does |
|---|---|
| `enabled` | Whether sign-in through this provider is accepted at all |
| `jit_provisioning` | Create an account the first time someone on a verified domain signs in |
| `jit_default_role` | The role a just-in-time account receives: `viewer`, `member` or `admin`. `owner` is never granted automatically |

## 4. Test a sign-in

Open the sign-in page in a private window, enter an address at the verified
domain and select **Continue with SSO**. The page asks the API where to send
you:

```bash
curl -s -X POST https://app.trustivan.com/api/v1/auth/sso/start \
  -H 'Content-Type: application/json' \
  -d '{"email": "alice@acme.com"}'
```

```json
{ "sso": true, "redirect_to": "https://acme.okta.com/oauth2/v1/authorize?…", "provider": "oidc" }
```

`"sso": false` means no enabled provider is routed for that domain. The answer
is deliberately the same for an unverified domain, a disabled provider and a
domain nobody has claimed.

A sign-in that fails shows the person one generic error. The reason is in your
own audit trail, under **Settings → Audit log** or `GET /api/v1/identity/audit`,
where a refused assertion is recorded with what was wrong. Check there first.

Your provider must assert an address inside a domain you verified. An assertion
for any other address is refused, whatever the provider says.

## 5. Map directory groups to roles

A group appears under **Directory groups** once a sign-in assertion names it,
and grants nothing until you map it. A mapping can raise someone above the
default role; it never lowers them below it.

```bash
curl -s -X PATCH "https://app.trustivan.com/api/v1/identity/groups/$GROUP_ID" \
  -H 'Content-Type: application/json' \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
  -d '{"granted_role": "admin"}'
```

`granted_role` is `viewer`, `member`, `admin`, or an empty string to clear the
mapping. `owner` is refused.

## 6. Require single sign-on

Do this last, after at least one owner has signed in through the provider.
Turn on **Require single sign-on**, or send the same `PUT` as before with
`"enforced": true`.

Once it is required, a password or social sign-in for an address in your
verified domain is refused with `sso_required`, and existing password sessions
end at their next renewal.

<Warning>
  Enrol a second factor on at least one owner account **before** you turn this
  on. An owner with a confirmed second factor can still sign in with password
  and code when your identity provider is down; nobody else can. Every such
  sign-in is recorded as `sso_enforcement.bypassed`. See
  [Set up multi-factor authentication](/how-to/set-up-multi-factor-authentication).
</Warning>

## Turning it off

| To | Do this | Effect |
|---|---|---|
| Stop accepting sign-in through the provider, quickly | `POST /api/v1/identity/provider/enabled` with `{"enabled": false}` | Nothing else is resubmitted or revalidated, which is why it is its own endpoint |
| Remove the provider | `DELETE /api/v1/identity/provider` | Memberships survive. The links between accounts and directory identities are removed |
| Drop a domain | `DELETE /api/v1/identity/domains/{id}` | Stops routing future sign-ins. Existing accounts and memberships are untouched |
| Unlink one person from the directory | `DELETE /api/v1/identity/identities/{id}` | The account and membership survive. Use it when a directory account is rebuilt and arrives with a new subject |

`GET /api/v1/identity/identities` is the access review: who can sign in through
the directory, as whom, and when they last did.

## See also

- [Provision users with SCIM](/how-to/provision-users-with-scim): have your
  directory create and remove access.
- [Tenancy and isolation](/concepts/tenancy): how seats, just-in-time
  accounts and enforcement interact.
- [Audit trail](/concepts/audit-trail): what identity changes are recorded.
