7c. Sign in with your identity provider (0.27.0)
Accounts are created by hand, one at a time, by an admin or by whoever holds PSTACK_TOKEN. That
does not scale past a couple of people. Point this host at the identity provider your organisation
already runs and anyone who can authenticate against it can sign in — no per-user setup here at
all. Decide what that provider’s defaultRole is before you do
(7e): it decides what everyone who walks through the door
can reach. Leaving it empty inherits the host’s default_role
(Runtime settings) — which is viewer until somebody raises it, and is
capped below admin on the way in, so an inheriting provider can never mint an administrator
however the host default is set. To have this provider mint admins, choose admin here.
You are configuring your own OAuth/OIDC application. Nothing is registered with anyone, no directory is copied, and nothing is synchronised.
A host holds as many providers as you like — GitHub for the engineers and Google for everyone
else is the ordinary case, not a special one. Each is stored under a short key you choose
(lowercase letters, digits and dashes: github, corp, okta-staging), the login page draws one
button per enabled provider, and everything keyed — the button, /start, the delete — names a
provider by that key.
Set it up
Section titled “Set it up”-
Copy the callback URL from Sign-on in the UI (or
GET /api/sso/config). It is always:https://control.<your-domain>/api/auth/sso/callbackOne fixed path for every provider. It must match what you register on their side exactly — a mismatch is the most common failure in this protocol, and the error the provider returns rarely says so.
-
Create the application in your provider, with that callback URL. Where exactly, per provider, is the next section.
-
Paste the client id and secret into the Sign-on page, or:
Terminal window # A preset knows its own mode — {"provider":"google"} is enough to mean OIDC,# and everything else is discovered from the issuer.curl -s -X PUT https://api.preview.example.com/api/sso/config \-H "Authorization: Bearer $PSTACK_TOKEN" -H 'content-type: application/json' \-d '{ "key": "google", "provider": "google", "clientId": "…", "clientSecret": "…" }'# OAuth 2.0 — the preset fills in the endpoints, the scopes and the claim mappingcurl -s -X PUT https://api.preview.example.com/api/sso/config \-H "Authorization: Bearer $PSTACK_TOKEN" -H 'content-type: application/json' \-d '{ "key": "github", "provider": "github", "clientId": "…", "clientSecret": "…" }'The issuer is fetched while you save, so a typo is refused there rather than discovered at somebody’s first login attempt.
keyis optional exactly as far as compatibility needs it to be: a keyless save on an empty host derives the key from the config (the provider name, oroidc), and on a one-provider host replaces that one provider — so a script written before keys existed keeps working. With several providers configured a keyless save is refused, naming the keys, because which one to replace is not this API’s guess to make.
A Continue with … button per enabled provider then appears on the login page of both UIs.
The two modes
Section titled “The two modes”| OIDC (prefer this) | OAuth 2.0 | |
|---|---|---|
| You provide | issuer (or discoveryUrl), clientId, clientSecret |
provider preset, clientId, clientSecret |
| Endpoints | discovered from /.well-known/openid-configuration |
from the preset, or typed for custom |
| Identity from | the ID token’s claims, signature-verified against the provider’s JWKS | the user-info endpoint, mapped by claimMap |
| Use it for | Google Workspace, Okta, Entra, Auth0, Keycloak, Authentik, … | GitHub, GitLab, Bitbucket, anything without user-facing OIDC |
Presets ship for GitHub, GitLab, Bitbucket (OAuth 2.0), Google, Microsoft, Okta, Auth0,
Keycloak (OIDC) and custom. A preset is only a set of defaults — every field stays editable, so
a self-hosted GitLab is the gitlab preset with three URLs replaced, not a custom provider typed
out by hand.
GitHub does publish an OIDC discovery document, and it is a trap. It signs GitHub Actions job tokens for cloud workload identity — it is not a user login endpoint. GitHub user login is OAuth 2.0, here and everywhere.
Where to create the app, per provider
Section titled “Where to create the app, per provider”Every walkthrough ends the same way: paste this host’s callback URL into the field the provider
calls its redirect URI, whatever it names that field. The same hints ship in the API (presets[]
carries setupUrl and setupHint), so the Sign-on form shows them beside the fields.
- GitHub — an OAuth App under Developer settings;
an org-owned app works the same way. The callback URL goes in as the Authorization callback
URL. The preset’s
read:user user:emailscopes cover sign-in —user:emailbecause a profile email is private by default and served from a second endpoint. Addread:orgonly for a group rule (below). - GitLab — an application under your user or group settings;
the callback URL is the Redirect URI.
read_usercovers sign-in; addread_apifor a group rule. A self-hosted GitLab is this preset with the three endpoint URLs pointed at your host. - Bitbucket — an OAuth consumer in your workspace settings
(Atlassian’s walkthrough);
the callback URL is the Callback URL.
account emailis all sign-in needs — Bitbucket serves the address from a second endpoint always, soemailis not optional. - Google — an OAuth client ID of type Web application on the Google Cloud console’s
Credentials page (the console walks you
through the consent screen first if you have none); the callback URL is an Authorized redirect
URI. The issuer is
https://accounts.google.comand the defaultopenid email profilescopes are all sign-in needs. To restrict sign-in to your Workspace domain, useallowedEmailDomains— the provider-side alternative is an Internal consent screen, and both is fine. - Microsoft — register an application in Microsoft Entra ID
(App registrations), create a client secret under Certificates & secrets, and put the
callback URL in as a Web redirect URI. The preset’s issuer is a template —
https://login.microsoftonline.com/<tenant-id>/v2.0— and the tenant id is required, not a nicety: Microsoft’s multi-tenantcommon/organizationsdiscovery documents publish the literal string{tenantid}as their issuer, and this host verifies an id token’s issuer against the discovery document verbatim, so the placeholder issuer would rightly refuse every login. A single-tenant URL has a real issuer and works. Your Directory (tenant) ID is on the app’s overview page. - Okta — an OIDC Web Application in the admin console (Applications → Create App
Integration; Okta’s guide);
the callback URL is the Sign-in redirect URI. Replace
<your-domain>in the template with your Okta domain —/oauth2/defaultis the org’s default authorization server, which most orgs use. - Auth0 — a Regular Web Application in the
dashboard; the callback URL is an Allowed
Callback URL. Replace
<your-tenant>with your tenant — copy the Domain field from the application’s settings, because a region suffix (.eu.auth0.com) may be part of it. - Keycloak — an OpenID Connect client in your realm’s admin console with client
authentication on (a confidential client, so it has a secret); the callback URL is a Valid
redirect URI. Replace
<host>and<realm>in the template with your own.
Four of those issuers are templates, and the honesty is deliberate. Microsoft, Okta, Auth0 and
Keycloak have no single issuer — every tenant, domain or realm gets its own — so the preset ships
the URL’s shape with a <placeholder> where your value goes. Saving one with the placeholder
still in it is refused at save time with a sentence saying exactly what to replace; the UI renders
the placeholder as a field to fill in rather than a value to accept. A preset that quietly pointed
everyone at a “default” that cannot work would cost each operator the same afternoon.
Who gets an account
Section titled “Who gets an account”By default, anyone who successfully authenticates. Your provider already owns that decision — Workspace restricts to internal users, a GitHub OAuth app can be org-approved — and duplicating it here would only be a second list to keep in step.
If you want a second list anyway: three allow rules, the endpoint one of them needs, and a placeholder.
| Field | Effect |
|---|---|
allowedEmailDomains: [] |
Non-empty ⇒ a login whose email is outside the list is refused. Fails closed: a provider that returns no address (a private GitHub profile) is refused too, not waved through |
allowedUsernames: [] |
Non-empty ⇒ a login whose username matches none of these glob patterns is refused. *, ? and character classes (qa-[0-9]*), matched case-insensitively; a malformed pattern (qa-[0-9) is refused when you save rather than left silently matching nobody. Fails closed the same way — see the warning below, because this one has a sharp edge |
requiredGroups: [] |
Non-empty ⇒ the provider is asked which groups/orgs this user belongs to, and a login in none of them is refused. Exact names, case-insensitive — not globs, because a GitLab group is a path (acme/backend) and * would not mean what you’d expect across the /. Needs a preset and a scope: see below |
groupsUrl |
Where that group list is read from. Filled in by the preset (https://api.github.com/user/orgs, https://gitlab.com/api/v4/groups); type your own for a self-hosted provider |
defaultRole |
The role an auto-provisioned account is created with — one of viewer, developer, maintainer, admin, or empty to inherit the host’s default_role (Runtime settings), which is viewer until somebody sets it. Inheriting is resolved when an account is provisioned, not frozen when you save, so changing the host default changes what every inheriting provider mints. It is never admin by omission, and that is enforced rather than merely intended: an inheriting provider is capped below admin even if the host default IS admin, because otherwise two individually-sane settings compose into “any stranger who completes the OAuth flow is an administrator”. In 0.27.0 an omitted value meant admin outright, and with all three allow-lists empty (how every preset saves) that is exactly what happened. To have a provider mint admins you must say admin on that provider, deliberately |
The rules and together: each list is any-of, and every rule you set has to pass. They are per provider: each stored provider carries its own three lists, and a login is checked against the rules of the provider it came through — a GitHub org rule says nothing about who may sign in with Google.
A username rule on a provider that supplies no username locks out everyone, not no one. The username is whatever
claimMap.usernamenames in the provider’s answer —loginon GitHub,usernameon GitLab,preferred_usernameon OIDC. Plenty of OIDC providers send no such claim, and there is nothing to match against, so the rule refuses (this provider returned no username, and sign-in is restricted to specific usernames) rather than quietly passing. That is the same directionallowedEmailDomainsfails in, and it is deliberate — but on a provider you have not checked,allowedEmailDomainsis the safer rule to reach for. Log in once with the rule unset and look at the username you were given.
requiredGroups asks more of the configuration than the other two, and all of it is checked while
you save, not at somebody’s first login:
- An OAuth 2.0 preset —
githuborgitlab. The group list is a second call to a provider-specific endpoint, and only the preset knows which field of the answer names a group (loginfor GitHub,full_pathfor GitLab, so a GitLab rule is writtenacme/backend).custom,bitbucketand OIDC are refused outright: a discovery document declares no groups endpoint and there is no groups claim in the mapping, so an OIDC group rule could only ever fail every login. - The scope that endpoint needs, in
scopes—read:orgfor GitHub,read_apifor GitLab. Without it the answer omits private memberships or is refused outright, and a legitimate member is locked out with no diagnostic anywhere. The save refuses and names the scope. Adding it changes what/startasks the provider for, so expect a consent screen the next time people sign in. groupsUrl, if you moveduserInfoUrloff the preset’s host. A self-hosted GitLab’s access token is not sent to gitlab.com to ask what groups it is in, so the preset’s URL is not inherited once the endpoints stop being the preset’s. The response shape is still assumed to be the preset’s.
A group rule fails closed, in two deliberately different ways. Not a member is you are not in a group this host allows to sign in (…). A group list that never arrived — a revoked scope, a
rate limit, an outage — is your group memberships could not be determined, …, and carries what
the provider actually answered. The login is refused either way; the sentence is the difference
between adding somebody to a group and fixing your OAuth app.
An account is keyed on (provider, subject), never the email — someone changing their address
keeps their account, their history and their personal tokens. An address is used for exactly one
thing: adopting a local account that already exists with the same address, and only when the
provider says the address is verified. Give a local account an address when you create it
(POST /api/users { username, password, email }) if you want that to happen.
What a login actually does
Section titled “What a login actually does”GET /api/auth/sso/start?provider=<key> mints a state and a PKCE verifier, parks them — the
provider’s key alongside — for five minutes, and redirects to that provider.
GET /api/auth/sso/callback spends that state once, reads back which provider the login
started against (never “the” provider — a login begun against one row is completed against that
row’s endpoints, secret and allow rules, whatever changed meanwhile), exchanges the code (with the
verifier and the client secret), verifies the ID token or fetches the user, and sets the same
session cookie a password login sets. Failures land back on /login?sso_error=… with the
provider’s own words — prefixed with the provider’s label when the host has several, because two
buttons failing with identical sentences is undiagnosable.
?provider= is optional exactly where it can be: with one enabled provider a keyless /start
picks it — every login link that predates keys keeps working — and with several it lands on the
login page naming the keys, because which directory vouches for you is not a guess this host makes.
?next=/deployments/pr-7 on /start is carried through and returned to — same-origin paths only.
One subtlety worth knowing before you configure two rows against the same upstream: an account is keyed on the upstream directory (the OIDC issuer, or the preset for OAuth 2.0) plus the subject — not on your key. Two providers on the same GitHub preset therefore share accounts, which is correct: the same subject from the same directory is the same person, and renaming or re-creating a provider under a different key never orphans anybody.
Removing one
Section titled “Removing one”curl -X DELETE https://api.preview.example.com/api/sso/config/github -H "Authorization: Bearer $PSTACK_TOKEN"That provider is forgotten and its button disappears; every other provider keeps answering. A bare
DELETE /api/sso/config still works on a host with exactly one provider — what it meant before
keys existed — and refuses on a host with several, naming the keys. Nobody is deleted either
way — those accounts keep their personal tokens, and pointing the same provider back at this host
re-links them by subject (under whatever key — see above). Set a password on one
(PUT /api/users/:id/password) if someone needs to get in meanwhile.