DocsIntegrate
Single sign-on and SCIM
An organisation can sign in to Truehands Cloud with its own identity provider, over OpenID Connect. People then use Continue with SSO on the sign-in page. On top of that, an organisation can:
- give people a role and programs from their groups at the identity provider, with ordered mapping rules;
- require single sign-on, so passwords stop working for everyone but owners;
- let the identity provider create, update and deactivate members with SCIM 2.0.
Owners and admins set this up under Settings → Single sign-on. Changing it needs the sso.manage permission and a password confirmed in the last 10 minutes. A custom role can never hold it. Every change is in the audit log.
Truehands supports OpenID Connect only. It does not support SAML. SAML may be added later.
Before you start#
- The redirect URI. Your identity provider sends people back to exactly
https://<your server>/v1/sso/callback. Settings → Single sign-on shows it, with a copy button. It is built from the server's--public-url, so that must be the address people use. - Email domains. List the domains whose people may sign in, for example
example.com. Only verified emails in those domains get in. Then verify each domain with a DNS TXT record, so that people who type their work email reach your identity provider. - A sign-in name. People type their work email, or the organisation's sign-in name (such as
acme), after Continue with SSO. The sign-in name always works, even before any domain is verified. - The client secret is sealed with the server's secrets key and never shown again. Settings shows only that one is set and its last four characters. See Deployment for
TRUEHANDS_SECRETS_KEY. - Test connection fetches the identity provider's discovery document (
<issuer>/.well-known/openid-configuration) and its signing keys, and says what it found. Run it after saving.
Set up Okta#
- In the Okta Admin Console, go to Applications → Applications → Create App Integration. Pick OIDC - OpenID Connect and Web Application.
- Under Sign-in redirect URIs, paste the Truehands redirect URI. Keep the Authorization Code grant type. You need no sign-out redirect.
- Under Assignments, assign the groups whose people may sign in. Save.
- Copy the Client ID and the Client secret from the app's General tab.
- Add a groups claim. On the app's Sign On tab, edit OpenID Connect ID Token: set Groups claim type to Filter, the name to
groups, and a filter such as Starts withtruehands-. Truehands asks for thegroupsscope when Okta offers it. - In Truehands, enter the Issuer URL: your Okta domain, for example
https://example.okta.com. If you use a custom authorization server, enter its issuer instead, for examplehttps://example.okta.com/oauth2/default, and add the groups claim to its ID tokens there. - Enter the client ID and secret, your email domains and a sign-in name. Turn single sign-on on, save, and run Test connection. Then verify your email domains.
SCIM with Okta. On the app's General tab, under App Settings, turn on SCIM provisioning. If your Okta org does not offer it for this app, add the catalog app SCIM 2.0 Test App (OAuth Bearer Token) for provisioning only, assigned to the same groups. Then, on the Provisioning tab:
- SCIM connector base URL: the SCIM base URL from Truehands,
https://<your server>/scim/v2. - Unique identifier field for users:
userName. - Supported provisioning actions: Push New Users, Push Profile Updates and Push Groups.
- Authentication Mode: HTTP Header, with the SCIM token as the bearer token.
- Under To App, turn on Create Users, Update User Attributes and Deactivate Users.
- On Push Groups, push the groups your mapping rules name.
Set up Microsoft Entra ID#
- In the Microsoft Entra admin center, go to App registrations → New registration. Pick Accounts in this organizational directory only. Under Redirect URI, choose Web and paste the Truehands redirect URI.
- Under Certificates & secrets → New client secret, make a secret and copy its Value (not the Secret ID).
- Under Token configuration:
- Add groups claim. Pick Groups assigned to the application to keep tokens small. Entra sends no group list in a token for someone in more than 200 groups. For the ID token, keep Group ID: your rules then name group object IDs.
- Add optional claim → ID →
emailandxms_edov. Entra does not sendemail_verified. Truehands acceptsxms_edov(the email's domain is verified by its owner) in its place.
- In Truehands, enter the Issuer URL for your tenant:
https://login.microsoftonline.com/<tenant id>/v2.0. Use your tenant's id, notcommonororganizations. The Client ID is the app's Application (client) ID. - Under Enterprise applications → your app → Properties, set Assignment required to Yes. Under Users and groups, assign the groups whose people may sign in.
- Save in Truehands, run Test connection, and verify your email domains.
SCIM with Entra. Under Enterprise applications → your app → Provisioning, set the mode to Automatic:
- Tenant URL:
https://<your server>/scim/v2. Secret Token: the SCIM token. Press Test Connection. - Keep the default user mappings:
userNamefrom userPrincipalName,emails[type eq "work"].valuefrom mail, andexternalId. - Turn on group provisioning, set the scope to assigned users and groups, and start provisioning.
Entra provisions in cycles of about 40 minutes, so a change can take that long to reach Truehands.
Set up Google Workspace#
- In the Google Cloud console, open APIs & Services → OAuth consent screen and pick Internal, so only your Workspace accounts can sign in.
- Under Credentials → Create credentials → OAuth client ID, pick Web application. Under Authorized redirect URIs, paste the Truehands redirect URI. Copy the client ID and secret.
- In Truehands, enter the issuer
https://accounts.google.com, the client ID and secret, and your Workspace domains. Save, run Test connection, and verify your email domains.
Google does not put groups in ID tokens, and offers no SCIM for apps you add yourself. Two ways work well:
- Keep Assign roles from groups off, and invite people with the role you choose. They accept the invite with SSO.
- Or turn it on with only a default rule, for example Viewer. Everyone gets that role. To give someone more, detach them and change their role by hand.
Verify your email domains#
An email domain does two different jobs, and Truehands keeps them apart:
- Allowed for sign-in. Your list of allowed domains is checked only against ID tokens from your own identity provider. Any organisation may list any domain, and listing one blocks nobody: it lets in no one your identity provider did not sign in.
- Finding your organisation. When someone types a work email after Continue with SSO, Truehands sends them to the identity provider of the organisation that verified that email's domain. Only verified domains do this, and one organisation at most can verify a domain on a server. Until a domain is verified, its people type your sign-in name instead.
To verify a domain, publish one DNS TXT record. Settings → Single sign-on lists each allowed domain as Verified or Not verified, with the record to copy:
| Type | Name | Value |
|---|---|---|
| TXT | _truehands.<domain>, for example _app.truehands.io | truehands-verification=<token> |
Each organisation gets its own token for each domain. Add the record at your DNS provider, then press Verify. Truehands looks the record up (POST /v1/sso/domains/{domain}/verify) and marks the domain verified when it finds the exact value. DNS changes can take a while to reach everyone; if Verify says the record is missing, try again later. Verifying needs sso.manage, and every attempt is in the audit log (sso.domain_verified, or sso.domain_verify_failed with why).
- Checked once. A domain stays verified until you remove it from your allowed domains. Truehands does not look the record up again, so you may remove it afterwards; keep it if you might remove and add the domain again, since a new token is made then.
- Someone else verified it. Verify answers
409 domain_taken. If the domain is yours, ask the server's operator: they can take the other organisation's verification away (below). - Servers that cannot query DNS. An operator who has checked who owns a domain some other way marks it verified on the server, for an organisation that lists it. Both commands are in the audit log as the operator:
python -m truehands.server sso-domain verify --data var --org acme --domain example.com
python -m truehands.server sso-domain unverify --data var --org acme --domain example.com--org takes the organisation's id (org_…), its sign-in name or a member's username. unverify is also how an operator settles a domain that changed hands.
Who gets in#
A sign-in passes only when the identity provider's ID token passes every check, its email is verified (email_verified true, or Entra's xms_edov), and the email's domain is one of the allowed domains.
- The identity is the subject. Truehands stores the provider's issuer and subject (
issandsub) on the member. From then on, that pair is the person: a later change of email at the provider changes nothing. - The first sign-in links by email, once. When Truehands does not know a subject yet, it links it to the one active person of the organisation who has that verified email and no link yet, and audits it (
member.sso_linked). Another subject with the same email later is refused. - Owners are never linked by email. An owner signs in with their password and links their own account under Settings → Single sign-on (
POST /v1/sso/link, with the password confirmed recently). So whoever runs the identity provider cannot become an owner by making an account with an owner's email. - Never across organisations. A sign-in starts from one organisation's settings and only ever finds that organisation's members.
- New people. With Assign roles from groups on, someone unknown is created from the mapping, with no password. With it off, they are refused and asked to get an invite. An invite can be accepted with SSO; the person gets the invite's role. When the invite names an email, they must sign in as that email.
- Changing the issuer unlinks every member from the old one. They link again at their next sign-in, by verified email; owners link from Settings again.
When a sign-in fails, the console says why:
| Error | Meaning |
|---|---|
domain_not_allowed | The email's domain is not in the allowed domains. |
email_not_verified | The identity provider did not confirm the email. |
account_deactivated | The member is deactivated. |
no_role | No mapping rule gives this person a role, and there is no default rule. |
not_a_member | No account yet, and roles do not come from groups: ask for an invite. |
owner_must_link | An owner signs in with their password first and links their account. |
link_conflict | That email belongs to a member already linked to another subject. |
idp_error | The identity provider refused the sign-in, or could not be reached. |
token_invalid | The ID token failed a check. The audit log entry (auth.sso_failed) names which. |
state_invalid | The sign-in expired, was used already, or was started in another browser. |
Group mapping rules#
Turn on Assign roles from groups and list rules. Each rule names one group, as the identity provider sends it, and gives its members a role and programs.
- The first matching rule wins. Rules are read from the top. A person in several groups gets the first rule that names one of them, so the outcome is always predictable. A person holds exactly one role in Truehands: there is no union of roles to fall back on. Put the most powerful rules first.
- A default rule applies when none of a person's groups match. Without one, their sign-in is refused, and they are told to ask their admin.
- What a rule may give. A person's built-in role (not owner) or one of your custom roles, and all programs or some (program scopes). Owners and admins always see every program.
- Group values are compared without regard to case. Okta sends group names. Entra sends group object IDs unless you change it. With SCIM, a rule can name a group's display name or its external id.
Editing rules follows the same rules as granting by hand:
- It needs
sso.manage. A change to rules that give admin also needsteam.make_admin, with the password confirmed recently. - Nobody saves a rule that gives a permission they do not hold.
- A mapping never gives the owner role.
- Nobody saves rules that would change their own role or programs.
- A custom role a rule gives cannot be deleted until the rule changes.
Saving applies the rules at once to every managed member whose groups are known, and each change is in the audit log.
Where groups come from, person by person:
- For a member SCIM provisioned: from SCIM, once the identity provider has pushed at least one group to the organisation. The groups in their ID token then do not count.
- For everyone else, and before any group is pushed: from the groups claim of their last ID token.
So people who only sign in keep their groups when SCIM starts pushing groups for others. Without SCIM, Truehands learns about a change in someone's groups only at their next sign-in, so use SCIM to end access at once. Keys pause while a member has no matching rule and come back if a rule matches again; deprovisioning the member in the identity provider revokes them for good.
Managed members#
Members created or linked through single sign-on while Assign roles from groups is on are managed by SSO. So are linked members at their next SSO sign-in, unless they were detached, and members SCIM creates or links. Members shows a Managed by SSO badge.
- Their role and programs follow their groups. They are worked out again at every sign-in, every SCIM change and every save of the rules. Each change is audited (
member.role_changedandmember.programs_changed, with the rule and what caused it). - No matching rule means no access, and the keys pause. A managed member whose groups match no rule, with no default rule, is deactivated: their console sessions end, and their unused links and the pending invites they sent are revoked. Their key pairs and access key are not revoked: they pause. Every way in refuses a deactivated member's keys (HTTP Basic, the legacy access key, sessions opened with a key, the CLI and CI), so scripts using them get
401meanwhile. When a group gives the member a role again, they are reactivated and the same keys work again, with the role the rule gives. The audit log recordsmember.deactivatedwith"keys": "suspended"andmember.reactivatedwith"keys": "restored". Under Team & keys → API keys, paused keys are marked Paused and can be revoked for good. - No changes by hand. Changing a managed member's role or programs in Truehands is refused (
409 managed_by_sso). Change their groups at the identity provider instead. - Detach. An owner or admin can detach a member (
POST /v1/team/members/{id}/sso-detach, needingteam.change_role). They keep their role and programs, and keep signing in with SSO, and you change their role by hand from then on. The same rules as a role change apply, so nobody detaches themselves. It is audited asmember.sso_detached. A detached member whose keys paused for want of a rule gets them back if you reactivate them by hand. - Owners are never managed. A mapping never changes, demotes or deactivates an owner, so the last owner always stays.
- Admins can be demoted. The identity provider is the source of truth: when an admin's groups no longer give admin, the mapping demotes them.
- Your own account too. When you sign in with SSO while the rules are on, your role follows them like anyone's. Before your first SSO sign-in, check that a rule gives you the role you need. Once you are managed, Truehands refuses rules that would change your own role.
- Turning Assign roles from groups off stops managing everyone. Members accepted from an invite are not managed.
Require single sign-on#
With Require single sign-on on:
- Password sign-in is refused for every member but owners (
403 sso_required). Their password sessions end at once. - Owners keep their password. It is the way in when the identity provider is down or misconfigured, so a broken identity provider cannot lock the company out.
- Password links for members other than owners are refused, and unused ones stop working. Invites for them are accepted with SSO.
- Confirming with a password for a sensitive action is refused for members; they confirm at the identity provider instead.
- Key pairs and service accounts keep working.
Turning it on needs single sign-on to be on and a connection test that passes at that moment. It also must not lock you out: you must be an owner, or signed in with single sign-on. Single sign-on cannot be turned off while it is required.
If your identity provider stops working, an owner signs in with their password and turns Require single sign-on off.
Confirming for sensitive actions#
A single sign-on counts as a fresh confirmation for 10 minutes, like a password sign-in. After that, an action that needs a recent confirmation (making a key, granting admin, changing these settings) asks again. For someone signed in with SSO, the console opens a small window at the identity provider, which is asked to sign them in again (prompt=login and max_age=0). Truehands checks that the ID token's auth_time is no older than the request, and that it is the same person. The window then closes, and the console carries on with the action. Allow pop-ups for the Truehands address.
SCIM provisioning#
Under Settings → Single sign-on → SCIM provisioning, copy the SCIM base URL (https://<your server>/scim/v2) and make a token. The token is shown once. Truehands keeps only its SHA-256 and its last four characters, and shows when it was last used. Rotate makes a new one and stops the old one at once; Revoke stops provisioning. Making, rotating and revoking need sso.manage with the password confirmed recently.
The identity provider sends the token as Authorization: Bearer <token>. Each token may make 600 requests a minute; after that it gets 429 with Retry-After. Every change SCIM makes is in the audit log with via = scim.
| Endpoint | What |
|---|---|
GET /scim/v2/ServiceProviderConfig, /ResourceTypes, /Schemas | What Truehands supports: PATCH and filters, no bulk, no sorting, no ETags |
GET /scim/v2/Users | Users SCIM provisioned. filter (at least userName eq and externalId eq), startIndex and count (up to 200) |
POST /scim/v2/Users | Create a user, or link the member who has this email |
GET, PUT, PATCH, DELETE /scim/v2/Users/{id} | Read, replace, change (add, replace, remove, including active) and deactivate one |
GET /scim/v2/Groups, POST /scim/v2/Groups | List (filter by displayName) and create groups |
GET, PUT, PATCH, DELETE /scim/v2/Groups/{id} | Read, replace, change members (add, remove) and delete a group |
- A created user is a person with no password, who signs in with SSO. Their role comes from their groups through the mapping. Without a matching rule (or with Assign roles from groups off), they are created inactive, and they become active when a group gives them a role.
- An existing member with the same email, not linked to SCIM yet, is linked instead of created (
member.scim_linked). DELETEdeactivates and never deletes. The member's runs and audit history stay. SCIM then answers404for them.- Deprovisioning is offboarding: it revokes keys for good.
active: falseorDELETEends the member's console sessions and revokes their key pairs and access key at once (member.deactivatedwith"keys": "revoked"). That includes keys that had paused because no rule matched (key.revoked, with"reason": "inactive_in_identity_provider"). They cannot sign in again until the identity provider reactivates them, and their old keys never come back: they make new ones. An admin cannot reactivate them by hand while the identity provider says inactive. - Losing every group that gives a role is not deprovisioning. The member is deactivated and their keys pause until a group gives them a role again (managed members). To end someone's access for good, deprovision them in the identity provider.
- Groups feed the mapping. Adding someone to a group, removing them, renaming or deleting a group works out their role again.
Truehands accepts what Okta and Microsoft Entra ID actually send:
- an
opin any case ("Replace"), and PATCH bodies without the PatchOp schema; activeas the string"False"or"True";- a
valueobject withoutpath, whose keys may be paths ({"name.givenName": "Ada"}); members[value eq "…"]remove paths, and remove with a list of members;emails[type eq "work"].value;- attributes Truehands does not keep (title, phone numbers, the enterprise extension), which are ignored.
Errors use SCIM's format ({"schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"], "status": "409", "scimType": "uniqueness", "detail": "…"}): 409 uniqueness for a taken userName or group name, 404 for an unknown id, 400 with invalidFilter, invalidValue or invalidSyntax, and 401 for a wrong token.
Owners. SCIM never provisions, changes, deactivates or deletes an owner. Such a request gets a SCIM error (409 for a create, 403 otherwise) and a scim.owner_refused entry in the audit log. So the last owner can never be removed from the identity provider's side.
Security#
- The protocol. The OpenID Connect Authorization Code flow with PKCE (S256),
stateandnonce. Each sign-in's state is stored as a hash, bound to the browser that started it with a short-lived cookie (HttpOnly, SameSite=Lax, Secure on https, 10 minutes), and works once. A callback from another browser, a replayed state and an expired one all fail. The callback hands the console a one-time code in the URL fragment, which browsers never send to a server; the code works once, within 2 minutes, in that browser only. - The ID token. It passes only when all of these hold:
- its algorithm is one of
RS256,ES256,PS256: nevernoneor HMAC, so an HS256 token "signed" with the public key is refused; - its key is one the provider publishes, of that kind (RSA of at least 2048 bits, or EC P-256);
- the signature verifies;
issis exactly the issuer you entered;audcontains the client ID, andazp, when present, is the client ID;exp,iatandnbfhold, with 60 seconds of clock skew;nonceis the one sent for this sign-in;- for a confirmation,
auth_timeis no older than the request.
- its algorithm is one of
- The provider's keys are cached for 1 hour. A token that names an unknown key refreshes them, at most once every 30 seconds, so a provider's key rotation works and a flood of unknown keys cannot hammer the provider.
- Requests to the identity provider go through the same guard as webhooks: https only, every address the host resolves to must be public, the connection goes to the checked address, TLS checks the real host name, redirects are not followed, timeouts and answers are small, and proxy settings are ignored.
- Secrets. The client secret is sealed with AES-256-GCM under the server's secrets key (Deployment) and never returned. The SCIM token is stored as its SHA-256. The audit log gets only their last four characters.
- Email domains route sign-ins only once verified with a DNS TXT record, and only to the one organisation that verified them, so nobody can send another company's people to their own identity provider by listing its domain. The lookup asks for TXT records only, with short timeouts, and reads at most 10 records and 512 bytes.
- The audit log records settings changes (
sso.configured,sso.tested,sso.required_on,sso.required_off,sso.mapping_changed,sso.domain_verified,sso.domain_verify_failed,sso.domain_unverified), SCIM tokens, sign-ins (auth.signed_inwithmethodsso), failures with the failing check (auth.sso_failed), links, detaching, and every change the mapping or SCIM makes to a member. Filter it byvia=ssoorscim.
Endpoints#
| Endpoint | Who | What |
|---|---|---|
GET /v1/sso | sso.view | The settings, the redirect URI, the mapping rules and SCIM's status. client_secret is only {"set", "hint"}. domains lists each allowed domain with verified, verified_at, verified_how (dns or operator) and the TXT record that verifies it. |
PUT /v1/sso | sso.manage | {"slug", "issuer", "client_id", "client_secret", "allowed_domains", "email_claim", "groups_claim", "enabled"}. Leave client_secret out to keep it. |
POST /v1/sso/test | sso.manage | Fetch the discovery document and keys now: {"ok", "steps", "discovery", "keys"} |
POST /v1/sso/domains/{domain}/verify | sso.manage | Look up the domain's TXT record and mark it verified (422 domain_not_verified, 409 domain_taken, 502 dns_unavailable) |
PUT /v1/sso/require | sso.manage | {"required": true}: see Require single sign-on (409 sso_not_ready, 409 would_lock_you_out) |
PUT /v1/sso/mapping | sso.manage, and team.make_admin for rules that give admin | {"enabled", "rules": [{"group", "role", "programs"}], "default": {"role", "programs"}} |
POST /v1/sso/scim-token, DELETE /v1/sso/scim-token | sso.manage | Make or rotate the SCIM token ({"token", "hint", "base_url"}, shown once), or revoke it |
POST /v1/team/members/{id}/sso-detach | team.change_role | Stop managing a member by SSO |
POST /v1/sso/start | anyone | {"email"} (its domain must be verified, else 404 domain_not_routed), {"org"} (the sign-in name) or {"invite_token"} → {"authorize_url"}, and the cookie that binds the sign-in to the browser |
GET /v1/sso/callback | the identity provider | The redirect URI. Sends the browser to /sso/finish |
POST /v1/sso/session | the same browser | {"code"} → a session like POST /v1/session, with "method": "sso" |
POST /v1/sso/step-up | a person signed in | Confirm at the identity provider → {"authorize_url"} |
POST /v1/sso/link | a person, confirmed recently | Link your account → {"authorize_url"} |
GET /v1/me carries auth.method (password, sso or key), auth.step_up (how this person confirms: password or sso) and sso (available, required, linked, managed). Member views carry sso (linked, managed, provisioned) and deactivated_by.