# Single sign-on

> Sign in through your identity provider (OpenID Connect, or SAML through WorkOS), provision people with SCIM, and require SSO.

Availability: Team service.

An organization can let its people sign in to Lanekeeper through its own identity provider (Okta, Entra ID, Google
Workspace, Keycloak, or any OpenID Connect provider).

## Connect your identity provider

1. In your identity provider, create an OpenID Connect web application: authorization code flow, client
   authentication `client_secret_basic`, scopes `openid email profile`. Register the redirect URI shown in the
   dashboard under Settings → Single sign-on.
2. In Settings → Single sign-on, an owner or admin enters:
   - the **issuer URL** (https; its `/.well-known/openid-configuration` must name the same issuer)
   - the **client id** and **client secret**
   - the **email domains** allowed to join, for example `acme.com`
3. People choose "Single sign-on" on the sign-in page and enter their work email (once you've verified your domain,
   below) or the organization's short name.

## SAML, through WorkOS

For a SAML identity provider (or any other protocol WorkOS supports), connect it to a WorkOS organization, then in
Settings → Single sign-on choose "SAML or another protocol, through WorkOS" and enter the **WorkOS organization ID**
(`org_…`), your WorkOS **client ID** and **API key**, and the allowed email domains. Register the redirect URI shown
there with WorkOS. Lanekeeper accepts only sign-ins whose WorkOS profile belongs to that organization, and, since
WorkOS doesn't verify email addresses, only emails in your allowed domains.

## Verify your domain

Under Settings → Verified domains, add your domain and publish the TXT record it shows (`_lanekeeper.<domain>`),
then choose Verify. Once verified, people can start single sign-on with their email address. A domain can be
verified by one organization only.

## Directory sync (SCIM)

Under Settings → Directory sync, turn SCIM on to get a token, then in your identity provider's provisioning settings
enter the base URL shown there (your server's API URL followed by `/v1/scim/v2`) and the token as a bearer token. Your
provider then adds people as members and removes them when they're deactivated or deleted (the last owner is never
removed); someone deactivated can't sign in with single sign-on either. The first SSO sign-in of a provisioned
person reaches the account the directory created for them. Groups aren't mapped yet: change roles in Settings →
Members.

The first time someone signs in, their Lanekeeper account is created and they join the organization as a member.
They can only sign in if their email is in one of your domains and your provider doesn't mark it unverified, even
when the provider lets anyone sign up. SSO accounts are never merged with existing GitHub accounts by email.

## Require SSO

With "Require SSO for admins and members", members reach the organization only through your identity provider:
in the browser, and with API tokens or `lk login` sign-ins created from an SSO session. Tokens made earlier from a
GitHub session stop working for them. Owners can always sign in with GitHub, so the organization can't be locked
out.

## How it's checked

Sign-in uses the authorization code flow with PKCE. Lanekeeper accepts an ID token only if:

- its signature verifies against your provider's published keys (RS256 or ES256; never unsigned)
- it was issued by your issuer, for Lanekeeper's client id
- it is current, and carries the one-time value from this sign-in

Sign-in can only start from the Lanekeeper sign-in page, so another site can't sign you in to an account that isn't
yours.

## Roles

SSO and SCIM members join as members. Owners can give anyone any role in Settings → Members; admins can move people
between member and admin.

## Not yet

Mapping your provider's groups to roles.
