---
title: Sign-in and OIDC SSO
description: "Complete self-host first-run administrator setup, invite members with passwords, and configure OpenID Connect SSO with allowed email domains for new SSO users."
---

Self-hosted Executor supports email-and-password accounts (by invitation after initial setup) and OpenID Connect (OIDC) single sign-on where new SSO users join by verified email domain without an invitation (**Self-host** only; **Local** uses a local API key and **Cloud** manages sign-in).

On first boot, open `<BETTER_AUTH_URL>` and complete **Set up Executor** to create the administrator account and the instance's one organization. To turn on SSO, set `SSO_DISCOVERY_URL`, `SSO_CLIENT_ID`, `SSO_CLIENT_SECRET`, and `SSO_ALLOWED_DOMAINS`, and register `<BETTER_AUTH_URL>/api/auth/callback/sso` in your identity provider.

**Prerequisites:** A running self-host container ([Self-host with Docker](/docs/run/self-host)) with `BETTER_AUTH_URL` matching the exact origin users open. For OIDC SSO, you need an OIDC identity provider with a final HTTPS discovery document URL and administrator access to register a redirect URI.

**You'll know it worked when** you can sign in to the dashboard as the organization owner, and (when SSO is configured) clicking **Continue with SSO** on `/login` completes sign-in with a test account at an allowed domain.

## First-run setup

A new self-host database starts with no users and no organization. Complete **Set up Executor** before anyone else can reach the instance — the first successful setup request creates the organization and assigns the `owner` role (see [Deploy, proxy, and tune self-host](/docs/run/self-host/deploy)).

1. Open `<BETTER_AUTH_URL>` in your browser. Until setup completes, Executor shows **Set up Executor** ("Create your administrator account and organization").
2. Enter:
   - **Organization name** (1 to 100 characters)
   - **Your name** (1 to 100 characters)
   - **Email**
   - **Password** (8 to 128 characters)
3. Click **Create administrator account**.

Executor creates the instance's single organization (with slug `executor`) and gives your account the `owner` role. The browser opens **Connect your assistant** (`/org/executor/setup/assistant`); complete onboarding to open the dashboard. Afterward, `GET /api/auth/self-host/config` reports `setup: false`, and subsequent requests to create the first owner are refused with HTTP `403`.

You'll know it worked when onboarding finishes in the dashboard and `curl -sf http://127.0.0.1:4400/api/auth/self-host/config` returns `{"setup":false,...}`.

## Passwords and invitations

Self-host disables open self-registration (`disableSignUp: true`), allows only one organization per instance, and does not show Cloud's Google, GitHub, ChatGPT, or passkey sign-in buttons.

To add teammates with password accounts:

1. As an organization `owner` or `admin`, open **Members → Add member**, enter the recipient's email, choose a role (**Member** or **Admin**), and click **Create invite link**, then **Copy link**.
2. The recipient opens the link:
   - If already signed in with the invited email address, they see **Join an organization** and click **Accept invitation**.
   - If not signed in, they click **Join with this invitation** on the sign-in page, fill **Your name**, **Email**, and **Password** (8 to 128 characters, or their existing password if they already have a password account) on **Join Executor**, and click **Accept invitation**.

## OIDC SSO and allowed domains

Configure OIDC SSO with four environment variables on the self-host container:

| Variable | Required when SSO is on | Purpose |
| --- | --- | --- |
| `SSO_DISCOVERY_URL` | Yes (triggers SSO when non-empty) | Final absolute `https://` URL of your IdP's `.well-known/openid-configuration` document (must not rely on HTTP redirects). Leave unset or empty to keep SSO off. |
| `SSO_CLIENT_ID` | Yes | OIDC client ID from your identity provider. |
| `SSO_CLIENT_SECRET` | Yes | OIDC client secret from your identity provider. |
| `SSO_ALLOWED_DOMAINS` | Yes | Comma-separated list of verified email domains allowed to join the organization as **new SSO users** (at least one domain required; exact match, case-insensitive). |

Register this exact callback URL in your identity provider:

```text
<BETTER_AUTH_URL>/api/auth/callback/sso
```

When you restart the container with all four variables set:

1. Executor fetches `SSO_DISCOVERY_URL` (10-second timeout, no HTTP redirects) and validates that the discovery document advertises a non-empty `id_token_signing_alg_values_supported` list plus absolute `https://` URLs for `issuer`, `authorization_endpoint`, `token_endpoint`, `jwks_uri` (and optional `userinfo_endpoint` and `end_session_endpoint`).
2. Executor requests scopes `openid`, `email`, and `profile` and verifies the ID token (`requireIdTokenVerification: true`).
3. Once first-run setup is complete, `/login` shows **Continue with SSO**.
4. New SSO users must have a **verified email** from the identity provider at an exact domain listed in `SSO_ALLOWED_DOMAINS`, and can join the organization as a `member` without an invitation. Existing memberships and linked sign-in methods require their own access changes in **Members** if you later remove a domain from `SSO_ALLOWED_DOMAINS`.
5. An existing password user cannot automatically merge into SSO on `/login` (`account_not_linked`): they sign in with their password first and link SSO from **Account → Security → Connect SSO**.

You'll know it worked when container logs show no `SSO is unavailable:` discovery errors, `/login` displays **Continue with SSO** after setup, and clicking **Continue with SSO** completes sign-in with an allowed-domain test account. (`GET /api/auth/self-host/config` returning `"sso":true` confirms only that the SSO environment variables are set, not that discovery succeeded.)

## Session secret and origin

- `BETTER_AUTH_URL` must match the exact scheme, host, and port users open; a mismatch can break browser sign-in or redirect to the wrong origin.
- `BETTER_AUTH_SECRET` overrides the auto-generated `/app/data/auth-secret.key` session secret (must be at least 32 characters). Rotating `BETTER_AUTH_SECRET` invalidates current session cookies.

## Example

Replace the placeholder discovery URL, client ID, client secret, and domains below with your identity provider's actual values before starting the container:

```bash
docker run -d --name executor-v2 --init --restart unless-stopped \
  -p 127.0.0.1:4400:4400 -v executor-v2-data:/app/data \
  -e BETTER_AUTH_URL=https://executor.example.com \
  -e SSO_DISCOVERY_URL=https://idp.example.com/.well-known/openid-configuration \
  -e SSO_CLIENT_ID=your-oidc-client-id \
  -e SSO_CLIENT_SECRET=your-oidc-client-secret \
  -e SSO_ALLOWED_DOMAINS=example.com,subsidiary.example.com \
  ghcr.io/usefulsoftwareco/executor-selfhost:2.0.0-beta.79
```

Check startup health, inspect container logs for any discovery errors, and confirm the SSO variables are loaded:

```bash
curl -sf http://127.0.0.1:4400/health
docker logs executor-v2 2>&1 | grep -i sso || true
curl -sf http://127.0.0.1:4400/api/auth/self-host/config
# {"setup":true,"sso":true} (reports that SSO variables are set)
```

After completing first-run setup, open `/login`, click **Continue with SSO**, and complete a sign-in with a test account to verify discovery and the IdP callback end to end.

## Limits

- Setup (`/api/auth/self-host/setup`) and invitation registration (`/api/auth/self-host/register`) are rate-limited to **3 requests per 10 seconds** per client address.
- The `SSO_DISCOVERY_URL` request uses `https://` with a 10-second timeout and follows no HTTP redirects; the discovery document must advertise supported ID-token signing algorithms and absolute `https://` endpoints. If discovery fails or times out at startup, Executor logs the error and keeps SSO unavailable while password sign-in remains available.
- Setting a non-empty `SSO_DISCOVERY_URL` without `SSO_CLIENT_ID`, `SSO_CLIENT_SECRET`, or at least one entry in `SSO_ALLOWED_DOMAINS` fails settings validation before startup.
- New SSO users whose IdP does not mark their email as verified, or whose email domain is not an exact match in `SSO_ALLOWED_DOMAINS`, are rejected at admission. Existing memberships and linked sign-in methods require separate access changes.
- Self-host supports exactly one organization per instance; users cannot create additional organizations or delete the organization.

## Related

- [Self-host with Docker](/docs/run/self-host)
- [Deploy, proxy, and tune self-host](/docs/run/self-host/deploy)
- [Operator OAuth clients](/docs/run/self-host/oauth-clients)
- [Storage, backups, and updates](/docs/run/self-host/storage-and-updates)
- [Organizations and access](/docs/concepts/organizations-and-access)
