<!-- Generated from the canonical OpenPost public page. Do not edit this build artifact. -->

Title: Set up single sign-on
Description: Let people sign in with OIDC, Google, or a trusted proxy, and keep a recovery account.
Canonical: https://openpo.st/docs/self-hosting/sso
Source: [https://openpo.st/docs/self-hosting/sso](https://openpo.st/docs/self-hosting/sso)

# Set up single sign-on

An instance administrator turns on one sign-in method for the whole server. Organization administrators can then add their own OIDC providers and rules in **Settings → Advanced → Single sign-on**. Passwords keep working unless an organization requires SSO.

**Before you start:**

- An instance administrator account
- `OPENPOST_PUBLIC_URL` set to your public HTTPS origin, because sign-in callbacks are built from it
- For OIDC, an identity provider that publishes OpenID discovery for its issuer URL

## Choose a sign-in method

  **OIDC**

  **Step 1: Register OpenPost with your identity provider.**

Create a confidential web client and add this redirect URI, using your own domain:

```text
https://post.example.com/api/v1/auth/oidc/instance/callback
```

  **Step 2: Set the provider in your environment.**

```dotenv
OPENPOST_OIDC_ISSUER=https://id.example.com
OPENPOST_OIDC_CLIENT_ID=your-client-id
OPENPOST_OIDC_CLIENT_SECRET=your-client-secret
OPENPOST_OIDC_NAME=Company sign-in
```

  **Step 1: Recreate OpenPost and sign out to test.**
The login page shows a button named after `OPENPOST_OIDC_NAME`.

You can also enter these values in **Settings → Advanced → Configuration → Authentication**. The issuer and client ID must be set together.

| Variable                            | Default                    | Effect                                                                                                                                          |
| ----------------------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `OPENPOST_OIDC_NAME`                | `Single sign-on`           | The label on the login button.                                                                                                                  |
| `OPENPOST_OIDC_SCOPES`              | `openid profile email`     | Scopes to request, separated by spaces or commas.                                                                                               |
| `OPENPOST_OIDC_JIT_ENABLED`         | `false`                    | Creates a passwordless account on a first sign-in with a verified email. An existing account with the same email is never linked automatically. |
| `OPENPOST_OIDC_BOOTSTRAP_ALLOWLIST` | Empty                      | People who become instance administrator when created this way: an email, or `ISSUER\|SUBJECT`.                                                 |
| `OPENPOST_OIDC_NATIVE_CALLBACK_URL` | `openpost://oidc/callback` | Where the mobile app receives a one-time handoff code after sign-in. Change it only for a custom app link.                                      |

  **Google**

  **Step 2: Create a Google OAuth client.**

In [Google Cloud Console](https://console.cloud.google.com/), create an **OAuth client ID** of type **Web application** and add this authorized redirect URI:

```text
https://post.example.com/api/v1/auth/oidc/google/callback
```

  **Step 3: Set the client in your environment.**

```dotenv
OPENPOST_AUTH_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
OPENPOST_AUTH_GOOGLE_CLIENT_SECRET=your-client-secret
```

  **Step 1: Recreate OpenPost and test.**
The login page offers Google. The server refuses to start if only one of the two values is set.

Google sign-in can create a new account on first use, requires a verified email, and never links to an existing account with the same email. It requests `openid profile email`.

  **Trusted proxy**

Use this when a platform in front of OpenPost already signs people in. OpenPost trusts two headers from the proxy and creates each person's workspace on first access.

  **Step 2: Set a shared secret.**

```dotenv
OPENPOST_PROXY_AUTH_SECRET=a-random-value-of-at-least-32-characters
OPENPOST_PROXY_AUTH_WORKSPACE_NAME=Team workspace
```

  **Step 3: Have the proxy add both headers.**

```nginx
proxy_set_header X-OpenPost-Proxy-User $trusted_user;
proxy_set_header X-OpenPost-Proxy-Secret $openpost_proxy_secret;
```

`X-OpenPost-Proxy-User` is a stable user ID or an email address. `X-OpenPost-Proxy-Secret` is the exact secret. The first person to arrive becomes instance administrator.

**Keep OpenPost private behind the proxy:**
  The proxy must delete any client-supplied copies of both headers before adding its own, and
  clients must not reach OpenPost's port directly. Otherwise anyone can sign in as anyone. If your
  proxy cannot guarantee this, use the built-in sign-in. This mode works only with the default
  `selfhost` edition. A wrong secret returns `401`.

## Add providers per organization

Organization administrators open **Settings → Advanced → Single sign-on**. **Identity providers** takes an exact issuer URL, client ID and secret, scopes, claim names, and options such as **Create assigned users on first sign-in** and **Require a verified email**. After saving, copy the **Sign-in callback URL** and **Back-channel logout URL** into your identity provider. The issuer must use HTTPS on a public address, and Microsoft Entra needs a tenant-specific issuer.

**Verified domains** sends people to the right provider by their email domain after you add a DNS TXT record. **Access policy** sets **SSO mode** to Disabled, Optional or Required, and controls local passwords and tokens.

## Keep a recovery account

**Required SSO can lock you out:**
  With SSO mode set to Required, access depends on your identity provider. Configure a break-glass
  account before you save.

Set `OPENPOST_SSO_BREAK_GLASS_EMAILS` to the emails of existing instance administrators who may bypass Required SSO in a browser session:

```dotenv
OPENPOST_SSO_BREAK_GLASS_EMAILS=admin@example.com
```

Each account needs a local password and two-factor authentication or a passkey, or OpenPost skips it. The list is applied at every start, and an account removed from it loses the bypass.

**Troubleshooting**

 - **Sign-in fails at the provider.** Check that the issuer is exact, including any trailing path, and that the server can reach the provider's discovery document. - **New people cannot sign in for the first time.** `OPENPOST_DISABLE_REGISTRATIONS=true` also blocks accounts created at first sign-in, and an account that already uses the same email is never linked automatically. - **An administrator has no access.** Run `openpost grant-admin --email address@example.com` on the server.

## What's next

  - [Settings reference](https://openpo.st/docs/self-hosting/settings-reference): Every setting an administrator can change.
  - [Reverse proxy](https://openpo.st/docs/self-hosting/reverse-proxy): Forward headers and keep OpenPost private.
  - [Configuration](https://openpo.st/docs/self-hosting/configuration): How environment and app settings combine.
