# Single Sign-On (SSO)

> Set up single sign-on for your LearnHouse organization: pick a provider, limit email domains, auto-provision accounts and set the callback URL.

SSO lets members sign in to your organization through your company's identity provider. They use their work credentials and do not need a LearnHouse password.

> SSO needs the Enterprise plan on LearnHouse Cloud, or the [Enterprise Edition](https://docs.learnhouse.app/enterprise) when self-hosted.
> 

## Supported providers

| Provider | Description |
| --- | --- |
| [WorkOS](https://docs.learnhouse.app/enterprise/sso/workos) | SAML and OIDC through WorkOS, with a hosted setup portal for your IT team. Available when the instance has WorkOS credentials. |
| [Custom OIDC](https://docs.learnhouse.app/enterprise/sso/custom-oidc) | Connect any OpenID Connect provider directly: Microsoft Entra ID, Okta, Google Workspace, Keycloak, Auth0 and others |

## Setting up SSO

Go to **Developers** → **SSO**. Only the **Admin** role can change SSO, and the organization's [two-factor policy](https://docs.learnhouse.app/platform/users/two-factor) applies.

1. Pick the **SSO Provider** and fill in its settings (see the provider pages).
2. Set the options below.
3. Turn on **Enable SSO** and click **Save Configuration**.

<img src="/img/pages/enterprise/sso-settings.webp" alt="The SSO tab under Developers, with the SSO Provider set to WorkOS, the Enable SSO switch, Allowed Email Domains and Auto-provision Users" width={1600} height={900} style={{ borderRadius: 10 }} />

The provider cannot be changed once the configuration is saved. To switch providers, use **Delete SSO Configuration** and start again.

| Option | Description |
| --- | --- |
| **Enable SSO** | Allow users to authenticate using your organization's identity provider. |
| **Allowed Email Domains** | Comma-separated list of email domains allowed to sign in through SSO, for example `example.com, company.org`. Leave empty to allow all domains. Domains must match exactly: `example.com` does not cover `mail.example.com`. |
| **Auto-provision Users** | On by default. Automatically create accounts for first-time SSO sign-ins. When off, only people who already have an account can sign in. |

To make SSO the only way in, also restrict the [allowed sign-in methods](https://docs.learnhouse.app/platform/users/authentication#choosing-allowed-methods) to **SSO**.

## How members sign in

1. On your login page, the member clicks **Sign in with SSO**.
2. They are sent to your identity provider and sign in there.
3. The provider sends them back to LearnHouse, signed in.

## New accounts

With **Auto-provision Users** on, a member's first SSO sign-in creates their LearnHouse account:

- First name, last name, email and avatar come from the identity provider.
- They get the **User** role. A different default role can only be set through the API.
- The organization's member limit still applies.
- Their email counts as verified only if your organization has a verified [custom domain](https://docs.learnhouse.app/platform/organizations/custom-domains) for that email domain.

## Existing accounts

LearnHouse does **not** link an SSO identity to an existing account just because the email matches. An existing account is accepted only when:

- it was linked to this SSO identity before, or
- it has never signed in any other way and belongs only to this organization.

Otherwise the sign-in is refused, and the member is asked to sign in with their usual method. Backoffice accounts can never sign in through SSO.

> Members who sign in through SSO can be exempted from your two-factor requirement, since the identity provider handles it. See [Two-Factor Authentication](https://docs.learnhouse.app/platform/users/two-factor#requiring-2fa-in-your-organization).

## Callback URL

Your identity provider needs LearnHouse's callback URL:

```
<base URL>/api/v1/auth/sso/callback
```

LearnHouse builds it from `SSO_REDIRECT_URI_BASE`, or from `LEARNHOUSE_DOMAIN` when that is not set. On a self-hosted instance, set `SSO_REDIRECT_URI_BASE` to the public URL of your instance, including `https://`. To use a completely different URL, set `SSO_REDIRECT_URI` to the full callback URL instead.
