# Any OIDC provider (https://www.dessn.com/docs/sso/oidc)

Connect any OpenID Connect identity provider to Dessn, such as Microsoft Entra ID, Google Workspace or Auth0. Every value, and what Dessn requires.

You need to be an owner of your Dessn team, and able to create apps in your identity provider (IdP). SSO is
rolling out to Enterprise teams, switched on per team by Dessn: see the [overview](https://www.dessn.com/docs/sso) for how it works and what
it checks. For step-by-step guides, see [Okta](https://www.dessn.com/docs/sso/okta) and [JumpCloud](https://www.dessn.com/docs/sso/jumpcloud).

## The values
| In your IdP | Value |
| --- | --- |
| Application type | A **web application** (a confidential client) with the **authorization code** grant |
| Sign-in redirect URI | `https://create.dessn.ai/api/auth/sso/oidc/callback` The same for every team |
| Initiate login URI (optional, for a dashboard tile) | `https://create.dessn.ai/api/auth/sso/oidc/initiate/<connection-key>`: copy **Initiate login URI** from Dessn |
| Scopes | `openid email profile` |
| Client authentication | `client_secret_basic`, or `client_secret_post` |
| PKCE | Dessn always sends a PKCE challenge (S256). Require PKCE if your IdP offers the option |
| Refresh tokens | Not needed |

## Set it up
<Steps>
<Step>
### In Dessn: verify your domain
Open [create.dessn.ai/w/settings/security](https://create.dessn.ai/w/settings/security). Under **Domains**, add your
email domain, add the TXT record Dessn shows at your DNS provider, then press **Verify**. Under **Identity provider**,
choose **OIDC**: Dessn shows the values above, with your connection key filled in.
</Step>
<Step>
### In your IdP: create the app
1. Create an OIDC **web application** with the **authorization code** grant.
2. Set the **sign-in redirect URI** to `https://create.dessn.ai/api/auth/sso/oidc/callback`.
3. Optionally, set the **initiate login URI** (some IdPs call it the login URL) so a dashboard tile works.
4. Allow the scopes `openid`, `email` and `profile`, and make sure your IdP releases the `email` claim.
5. Assign the people or groups who should use Dessn.
6. Copy the **issuer URL**, the **client ID** and the **client secret**.
</Step>
<Step>
### In Dessn: connect it
Under **Identity provider**, with **OIDC** chosen, enter the **Issuer URL**, **Client ID** and **Client secret**.
Choose **New people join as**: **Editor** or **Viewer**. Press **Save**: Dessn reads your IdP's discovery document then.
</Step>
<Step>
### Test, then turn it on
Under **Sign-in**, press **Test sign-in** and sign in through your IdP as yourself. Then turn on **Single sign-on**.
Optionally, turn on **Require SSO** ([what it does](https://www.dessn.com/docs/sso#require-sso-and-the-break-glass-path)).
</Step>
</Steps>

## What Dessn requires
- **An https issuer with a discovery document.** Dessn reads `<issuer>/.well-known/openid-configuration`. The `issuer`
  in that document must match the issuer URL you entered exactly, trailing slash included.
- **Signed ID tokens.** The ID token must be signed with a key from your IdP's JWKS. Unsigned tokens (`alg: none`) are
  refused. Dessn checks `iss`, `aud` (your client ID), `azp` when present, `exp`, `iat` and `nonce`.
- **An email address.** Dessn reads the `email` claim from the ID token, else from the UserInfo endpoint. The address
  must be on a domain your team verified.
- **`email_verified`.** If your IdP sends `email_verified: false`, the sign-in is refused. If it doesn't send the claim,
  the address is accepted, because the domain check is the guard. **Auth0:** a user made with the dashboard's
  **Create User** form starts with `email_verified: false`, so Dessn refuses them until the address is verified in Auth0:
  have them open Auth0's verification email (the user's **Actions** menu, **Send Verification Email**), or set
  `email_verified` to `true` with Auth0's Management API (`PATCH /api/v2/users/{id}`).
- **A stable `sub`.** Dessn ties the person to your connection by `sub`. Names come from `name`, `given_name` and
  `family_name` when present.

Dessn authenticates to your token endpoint with `client_secret_basic`, or with `client_secret_post` when that's the only
method your discovery document lists. Some IdPs (JumpCloud) list both but take only the one the app is set to: when your
IdP refuses basic as `invalid_client`, Dessn tries `client_secret_post` once. It doesn't keep your IdP's access or refresh tokens.

## Issuer URLs
The issuer is the `issuer` value in your IdP's discovery document. Common ones:

| IdP | Issuer URL |
| --- | --- |
| Okta | `https://<your-org>.okta.com` (no trailing slash), or a custom authorization server's, like `https://<your-org>.okta.com/oauth2/default` |
| JumpCloud | `https://oauth.id.jumpcloud.com/` (with the trailing slash) |
| Microsoft Entra ID | `https://login.microsoftonline.com/<tenant-id>/v2.0` |
| Google Workspace | `https://accounts.google.com` |
| Auth0 | `https://<your-tenant>.auth0.com/` (with the trailing slash), or your custom domain. Users made with **Create User** must have their email verified first (see `email_verified` above) |

## Troubleshooting
| If Dessn says | Check |
| --- | --- |
| Saving fails, naming the issuer | The issuer starts with `https://`, serves `/.well-known/openid-configuration`, and matches that document's `issuer` exactly. |
| **Your company's sign-in didn't let you in.** | The person isn't assigned to the app in your IdP, or your IdP refused them. |
| **We couldn't confirm that sign-in with your company's identity provider.** | The client ID and secret are right, and the issuer matches. The ID token is signed with a key in your JWKS. |
| **Your company's sign-in didn't share an email address with Dessn.** | The `email` scope is allowed and your IdP releases the `email` claim. |
| **Your company's sign-in says that email address isn't verified yet.** | Your IdP sends `email_verified: false` for that person. In Auth0, users made with **Create User** start unverified: verify the address in Auth0. |
| **That address isn't on a domain this team has verified for single sign-on.** | The person's email is on a domain your Dessn team hasn't verified. Verify that exact domain. |
| **That sign-in took too long and expired.** | Start again: a sign-in attempt lasts 10 minutes. |
| **That sign-in started in another tab or browser.** | Start again, and finish in the same tab. |
| **The test sign-in reached your identity provider, but it signed in someone other than you.** | Your IdP signed in another account than the owner who pressed **Test sign-in**. Sign in at your IdP as yourself (sign out of it first if it remembers someone else). |
