Enterprise identity: SSO, SCIM, MFA
Three independent pieces, all configured under Settings → Security by an owner or admin and all exposed in the API: single sign-on through your identity provider (SAML 2.0 or OpenID Connect), SCIM 2.0 provisioning so the IdP creates, updates and deactivates members, and two-factor sign-in (TOTP authenticator apps with recovery codes) that an account can require of every member. API keys and OAuth clients are untouched by all three: they authenticate machines, not people.
Single sign-on
One connection per account. PrimaryCheck is the service provider; your IdP asserts who the person is, and the dashboard session is minted here. The values your IdP needs come back on every connection object as sp:
| Value | SAML | OIDC |
|---|---|---|
| Entity id / client | sp.entityId — https://api.primarycheck.com/sso/saml/{connectionId}/metadata (also the metadata URL) | the client id you registered at the provider |
| Callback | sp.acsUrl — https://api.primarycheck.com/sso/saml/acs (HTTP-POST) | sp.redirectUri — https://api.primarycheck.com/sso/oidc/callback |
| Start URL | sp.loginUrl — https://api.primarycheck.com/sso/{connectionId}/login | same |
| Metadata | download from GET /v1/account/sso/metadata or the public entity-id URL | discovery at {issuer}/.well-known/openid-configuration |
Configure
POST /v1/account/sso # owner or admin session
{ "type": "saml", "name": "Okta",
"saml": { "idpEntityId": "http://www.okta.com/exk…", "idpSsoUrl": "https://acme.okta.com/app/…/sso/saml",
"certificates": ["-----BEGIN CERTIFICATE-----
…"] },
"domains": ["acme.example"], # emails on these domains are sent to the IdP from /login
"jitEnabled": true, "defaultRole": "member", # create members on first sign-in
"groupRoleMap": { "PC-Admins": "admin", "PC-Viewers": "viewer" } }
POST /v1/account/sso
{ "type": "oidc", "name": "Entra ID",
"oidc": { "issuer": "https://login.microsoftonline.com/<tenant-id>/v2.0", "clientId": "…", "clientSecret": "…" },
"domains": ["acme.example"], "groupRoleMap": { "<group-object-id>": "admin" } }The OIDC client secret is sealed at rest and never returned (oidc.clientSecretSet). PATCH the same path to change anything; DELETE removes the connection and members return to emailed links. Attributes and claims are read with sensible defaults — SAML email / mail / the WS-Fed emailaddress claim, firstName / givenName, lastName / sn / surname, groups / memberOf; OIDC email / preferred_username, given_name, family_name, groups — and attributeMap overrides any of email, firstName, lastName, name, groups.
What happens at sign-in
- The person opens
sp.loginUrl(or types their email on /login, which asksPOST /v1/sessions/discoverand forwards them when the domain is routed). A single-use state is created: the SAML AuthnRequest id, or the OIDCstate+nonce+ PKCE verifier. - The IdP posts the SAML Response to the ACS, or redirects back with a code. Checks: assertion signature against the connection's certificate(s), audience = our entity id, destination/recipient = the ACS,
NotBefore/NotOnOrAfterwith 300 s drift,InResponseTowhen the flow started here, assertion-id replay store. OIDC: id_token signature via JWKS (one refetch on an unknownkid),iss,aud,nonce,exp/iatwith 120 s leeway; UserInfo is merged for groups. - The member is found by email, or created when
jitEnabled(role = the highest role any asserted group maps to, elsedefaultRole). For an existing member a matching group also updates the role (the last owner is never demoted). Deactivated members are refused. - A session is minted (
authMethod: "sso"; the IdP owns the second factor, so account MFA is not asked again), the httpOnlypc_sessioncookie is set, and the browser lands on/login/callback?token=ssoc_…— a two-minute single-use hand-off thatPOST /v1/sessions/exchangetrades for the bearer session the dashboard stores today.
Failures redirect to /login?error=<code> (saml_invalid, oidc_token_invalid, unknown_issuer, replay, state_invalid, domain_not_allowed, not_a_member, member_deactivated, email_missing…) and write an sso.login_failed audit row with the reason — never the assertion or token.
Enforcing SSO
After one successful sign-in through the connection, PATCH /v1/account/sso { "enforced": true }. From then on POST /v1/sessions and POST /v1/sessions/exchange answer 400 sso_required (with the loginUrl in error.errors[0]) for every member, and accepting an invite creates the membership but returns { ssoRequired: true, loginUrl } instead of a session. Existing sessions keep working. Disabling the connection clears enforced; enforcing before the first sign-in answers 409 sso_untested.
IdP walkthroughs
| Okta (SAML) | Microsoft Entra ID (SAML) |
|---|---|
Applications → Create App Integration → SAML 2.0. Single sign-on URL = sp.acsUrl; Audience URI = sp.entityId; Name ID format EmailAddress, application username Email. Attribute statements: email → user.email, firstName → user.firstName, lastName → user.lastName; group attribute statement groups with a filter (e.g. Starts with PC-). From the app's Sign On tab copy the Identity Provider Issuer (→ idpEntityId), Identity Provider Single Sign-On URL (→ idpSsoUrl) and the X.509 certificate. | Enterprise applications → New application → Create your own (non-gallery) → Single sign-on → SAML. Identifier (Entity ID) = sp.entityId; Reply URL (ACS) = sp.acsUrl; Sign on URL = sp.loginUrl. Default claims already carry …/claims/emailaddress, givenname, surname; add a group claim (Security groups, source attribute Group ID — or sAMAccountName / Cloud-only group display names if you want names in groupRoleMap). Copy Microsoft Entra Identifier (→ idpEntityId), Login URL (→ idpSsoUrl) and download Certificate (Base64). Keep Signing Option at "Sign SAML assertion" or "Sign SAML response and assertion"; encryption off. |
| Okta (OIDC) | Microsoft Entra ID (OIDC) |
|---|---|
Create App Integration → OIDC → Web Application. Sign-in redirect URI = sp.redirectUri; grant type Authorization Code (PKCE is used automatically). Issuer = https://<org>.okta.com (or your authorization server's issuer URL); groups need a groups claim on the authorization server (filter e.g. PC-.*). | App registrations → New registration → Web redirect URI = sp.redirectUri. Issuer = https://login.microsoftonline.com/<tenant-id>/v2.0; client id = Application (client) ID; create a client secret. Token configuration → add optional claim email (ID token) and a groups claim (Security groups → Group ID, or sAMAccountName for names). Entra's preferred_username is also accepted when email is absent. |
SCIM 2.0 provisioning
Base URL https://api.primarycheck.com/scim/v2, bearer token from POST /v1/account/scim/token (owner or admin; one active token per account, shown once; issuing a new one revokes the previous). A SCIM User is an account member (id = mem_…, userName = email); a SCIM Group grants a role when its displayName is in the SSO connection's groupRoleMap or it carries urn:primarycheck:scim:schemas:extension:2.0:Group.role. Members get the highest role of their mapped groups; a member in no mapped group keeps the role they have.
| Endpoint | Notes |
|---|---|
GET /ServiceProviderConfig · /ResourceTypes · /Schemas | Public. PATCH and filter supported; bulk, sort, etag not. |
GET /Users?filter=userName eq "…" | Also externalId eq, id eq; startIndex (1-based) and count ≤ 200. Other filters answer 400 invalidFilter. |
POST /Users | userName must be the email; name.givenName/familyName, externalId, active, roles[0].value (never owner) are honoured. 409 uniqueness on a duplicate. |
PATCH /Users/{id} | RFC 7644 operations including Entra's string booleans and path-less replace. active: false deactivates the member and revokes every session of that user on the account inside the request; active: true reactivates. The last owner cannot be deactivated (409 mutability). |
PUT /Users/{id} · DELETE /Users/{id} | Full replace; delete removes the membership (sessions revoked) and the member from every group. |
/Groups … | Create, list (displayName eq), get, replace, patch (add/remove/replace on members, members[value eq "id"] paths, rename), delete. |
Responses are application/scim+json; errors use the SCIM body { schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"], status, detail, scimType }. Okta: add the app's Provisioning integration with SCIM 2.0, base URL above, HTTP Header auth with the token, unique identifier userName; enable Create, Update, Deactivate and push groups. Entra ID: Provisioning → Automatic, Tenant URL = base URL, Secret Token = the token, then Test Connection; map userPrincipalName → userName, Switch([IsSoftDeleted]…) → active, givenName, surname, objectId → externalId.
Two-factor sign-in (TOTP)
POST /v1/account/mfa/totp/enroll → { secret, otpauthUrl, qrSvg, … } # nothing enforced yet
POST /v1/account/mfa/totp/verify { code } → { enabled: true, recoveryCodes: [10 codes] } # shown once
GET /v1/account/mfa → { enabled, method, recoveryCodesRemaining, required }
POST /v1/account/mfa/recovery_codes { code } → new codes (old ones void)
DELETE /v1/account/mfa/totp { code } → off (409 mfa_required_by_account while the account requires MFA)
# sign-in: a session arrives with mfaPending: true and may only call
POST /v1/sessions/mfa { code } → the full session (same token); TOTP or a recovery code
# anything else with a pending session answers 403 mfa_required; five wrong codes → 401 mfa_locked (session revoked)
PATCH /v1/account/security { "mfaRequired": true } # owner|admin who already has MFA; members without one enrol at their next sign-inSecrets are sealed at rest; a TOTP code is accepted once; recovery codes are stored hashed. When the account requires MFA, a member without an authenticator gets a session with mfaEnrollmentRequired: true that can only call the enrol/verify endpoints — verifying completes the sign-in. SSO sign-ins are not asked for a second factor (the IdP is responsible). Audit rows: mfa.enrolled, mfa.verified, mfa.failed, mfa.locked, mfa.recovery_codes, mfa.disabled, account.mfa_required; SSO: sso.config_changed, sso.login, sso.login_failed, sso.jit_created; SCIM: scim.token_created, scim.user_created, scim.user_updated, scim.user_deactivated, scim.user_deleted, scim.group_*.