Skip to content
LogoLogo

Enterprise SSO (SAML and OIDC)

Enterprise SSO lets one of your customers' companies sign its people in through the company's own identity provider (Okta, Microsoft Entra ID, Google Workspace or any SAML/OIDC provider). It can also provision and deprovision people over SCIM, and grant access from the company's groups. Each company is a connection: one identity provider for one of your tenants. You add connections while the deployment runs. No redeploy is needed.

Status: pre-release.

  • Not released yet. Sign-in through every provider below is tested end to end on a real deployment. SCIM is in preview. Domain enforcement and break-glass are tested end to end (cutover, sign-out, emailed code, alert). Dashboard tiles are not yet tested end to end.
  • Provider setups. The provider recipes in Provider setup are marked Supported or Supported (preview). Sign-in through Okta OIDC, Okta SAML, Entra OIDC, Entra SAML and Google OIDC is tested end to end (Cognito Lite), with groups, 5-minute tokens and the hosted refresh. SCIM with the providers' own provisioning clients is Supported (preview): tested end to end with Microsoft Entra ID and Okta.
  • Names are provisional. Every route, setting, claim, CLI command, error code and event type in these guides is pending the SSO naming review and may still change.
  • Pricing is not decided. SSO packaging and price are an open decision. These guides state no SaaSLayer price; the AWS Cognito plan SSO runs on, and what AWS charges for it, is under Cognito plan and AWS costs.

Where to start

Pick your combination

SSO works with either SaaSLayer service, or both. Each service stays independently deployable.

CombinationYou runPeople sign in withWho decides accessGuide
Auser-service + permissions-serviceSaaSLayer Users (SSO connections live in user-service)SaaSLayer Permissions, from group mappingsCombo A
Buser-service onlySaaSLayer UsersYour backend, from the token's SSO claims and the live status checkCombo B
Cpermissions-service + your own login providerYour provider (Okta, Entra, Auth0, WorkOS, Google)SaaSLayer Permissions, from issuer grants, SCIM and group mappingsCombo C

In A and B, SaaSLayer hosts the connection: the SAML/OIDC trust, the sign-in, the session, SCIM and the setup flow for the company's IT admin. In C, your provider handles sign-in and sessions. SaaSLayer only verifies the tokens, hosts a SCIM directory and grants access.

Turn SSO on (A and B)

SSO is off by default. Turning it on adds the sign-in triggers and the identity-provider permissions the connections need, and moves the user pool to the Cognito Essentials plan so its sign-in pages are Cognito managed login (see What people see). People who already sign in keep their accounts, sessions and sign-in methods.

saaslayer aws foundation upgrade                     # SSO needs foundation 8.4.0 or later in the target account
saaslayer deployment settings set --env prod --set user-service.EnableSso=true --reason "enterprise SSO for Acme"
  • Primary pool. SSO lives on the email primary pool. A phone-primary deployment is refused.
  • Foundation version. A deployment whose AWS account runs an older foundation is refused with SSO_FOUNDATION_UPGRADE_REQUIRED.
  • Connection limit. user-service.SsoMaxConnections caps the number of connections (default 300, which is Cognito's default identity-provider quota; up to 1000 after AWS raises the quota).
  • Turning SSO off works only once every connection is deleted (SSO_CONNECTIONS_EXIST otherwise).
  • Cognito plan. SSO runs the user pool on Essentials, in place: the same pool, users, app clients and connections. A pool already set to Essentials or Plus (UserPoolTier) stays on its plan. Turning SSO off returns the pool to Lite. See Cognito plan and AWS costs.

Then manage connections with saaslayer sso …, as a deployment owner signed in with saaslayer login --deployment. The console's SSO page and the hosted settings page use the same API. See each combination's guide for the flow.

How the pieces fit

One account, several identities

  • Account. A person is one SaaSLayer account (custom:suid), whatever way they sign in.
  • Directory identity. An SSO sign-in joins the account through the connection's directory identity. That is the provider's immutable user id: the Okta user id, the Entra object id (with its tenant id), the Google sub or a SAML persistent NameID.
  • Never the email. An email, a user name or a UPN never identifies anyone. A renamed or recycled address can't take over an account.
  • Cognito credential. Each connection has its own Cognito credential for the person (<provider>_<subject>). Cognito never links it to the person's password or social credential.
  • Adoption. The first SSO sign-in (or SCIM push) joins an existing account only when that account's verified email is in one of the connection's verified domains, and that account holds no identity in this connection yet. Otherwise it creates a new account.
  • Namespace lock. The identity namespace (issuer, providerTenant, subjectSource, and the OIDC client id) locks at first activation. A wrong one needs a new connection (SSO_IDENTITY_NAMESPACE_IMMUTABLE).

Domains: routing, not membership

A connection lists email domains. You prove control of each one with a DNS TXT record (_saaslayer-sso.<domain>; no other proof is accepted). A verified domain does three separate things:

  1. Routing. Email-first sign-in sends anyone@<domain> to the connection's provider (POST /api/auth/sso/discover). The answer never reveals which tenants use SSO.
  2. Trust of the provider's email. An IdP email inside a verified domain is accepted without email_verified. An email outside the verified domains refuses the sign-in.
  3. Enforcement (optional). Turning on --enforce ends password, social and passkey sign-in for the domain after a notice period (default 14 days, 0–90). People are emailed, and on the day their native sessions are signed out. A break-glass allowlist of up to 2 people per connection (plus the deployment owner) can unlock native sign-in with an emailed code during an identity-provider outage. Every use is audited and alerted. Both are emailed, so enforcement and the break-glass list need an email sender (the user-service CognitoEmailFromAddress setting, a verified SES identity); without one they are refused (SSO_EMAIL_SENDER_REQUIRED).

A domain never grants membership in an org or any permission. Access comes from groups and mappings (A, C) or your own logic (B).

Each verified domain is re-checked daily. After 14 days of failing checks it is demoted to unverified, and routing and email trust stop. A connection that is disabled enforces nothing.

Just-in-time sign-in or SCIM-only

  • JIT (default). --jit on creates or joins the account at the first sign-in.
  • SCIM-only. --jit off refuses anyone SCIM has not provisioned first. It requires --scim on.
  • Personal org. --create-personal-org off skips the personal org a new person would otherwise get.

Groups and who owns them

Each connection has one group authority: the source its people's groups come from.

AuthorityWhen it appliesWhere the groups come from
Sign-inFrom the connection's first activation, for every provider except GoogleEach sign-in: the OIDC ID token's groups claim, or the SAML groups attribute (else Entra's default group claim)
NoneFrom the first activation of a Google connectionNowhere: Google sends no groups
SCIMOnce you confirm the first full SCIM pushThe SCIM directory
  • Sign-in authority. Each sign-in replaces the person's groups with the list it carries. OIDC sign-ins are ordered by the ID token's issue time (iat), so a delayed older sign-in never replaces a newer list. A SAML assertion carries no issue time, so SAML sign-ins are ordered by arrival: a delayed older sign-in can briefly replace a newer list until the next sign-in. A sign-in without the claim, or with an overage, malformed or oversized list, counts as incomplete and grants nothing from groups. A token refresh doesn't carry groups, so a group removal applies at the person's next sign-in. Use SCIM when a removal must apply at once.

  • None (Google). The token's sso_groups is a complete empty list (sso_groups_truncated is "false"). Nothing is group-derived: no group mapping grants anything (not its default either), and no manager group matches.

  • SCIM authority. After the company's IT admin connects SCIM and the initial push finishes, confirm it:

    saaslayer sso scim sync-complete <connectionId>

    Until you confirm, the connection's earlier authority (sign-in or none) stays in force. After that, SCIM is the authority, and groups the provider asserts at sign-in are recorded only as drift; they never override SCIM.

  • Provider group ids. SCIM group members resolve only through SCIM user ids. A group is keyed by its SCIM externalId when the provider sends one (Entra object ids), else its displayName (Okta). Nested groups are refused.

  • Source-owned memberships (A, C). A membership or role that a mapping grants belongs to the source (sso:<connectionId> or the C issuer grant). A manual grant is kept beside it.

  • Losing the last source. When a person's last source for an org goes away, the membership and the manual roles in that org go too. The org's last Owner is never removed.

Sessions and tokens

SettingDefaultRangeWhat it does
--token-ttl-minutes55–60Lifetime of the connection's ID and access tokens.
--session-cap-hours121–24Fixed deadline from the sign-in time (auth_time). Refreshes and newer sign-ins never extend it.
--mfadelegateddelegated, saaslayerdelegated: the company's identity provider is the MFA. saaslayer: the person also enrolls a SaaSLayer TOTP or passkey, used only as a second factor (never to sign in).
--delegated-tokensblockedblocked, short_livedWhether an SSO session may mint Permissions session tokens (assumed roles, delegated sessions). short_lived caps them at 15 minutes and the session's deadline (A).
  • Session cap after an edit. Lowering the cap takes effect online at once (the user-service API, the status check and Permissions refuse an older session past its new deadline). Cognito keeps refreshing that older session until the deadline it fixed at sign-in, so a verifier that only checks the JWT offline catches up by then (24 hours at most).
  • Sensitive operations. Sensitive operations still need a fresh step-up (10 minutes): a fresh OIDC sign-in at the identity provider (OIDC with delegated), or a SaaSLayer TOTP or passkey. SAML can't prove a fresh IdP sign-in.
  • No native backup credentials. SSO people never get a password or passkey sign-in on the side. The break-glass allowlist covers identity-provider outages.

What people see

With SSO on, every Cognito sign-in page on the deployment's login domain is managed login, not the classic hosted UI:

  • A normal SSO sign-in goes straight from your app to the company's identity provider and back. No Cognito page shows.
  • A sign-in that waits at the identity provider for more than 5 minutes comes back to a Cognito sign-in page with one button for the company's provider. On managed login this page carries the deployment's brand: the logo and the accent color (primary button, links, focus) from the published email brand. Brand names don't appear: managed login has no place for them. Without a brand, Cognito's default style shows.
  • Error pages use the same style.
  • Your own app clients (the deployment's app and an additional app) show Cognito's default managed-login style.

A brand change reaches the connection's page the next time the connection is applied (any edit, an activation, or the next deploy, which re-applies every connection).

Cognito plan and AWS costs

SSO deployments use the Cognito Essentials plan: native-sign-in monthly active users cost $0.015 instead of $0.0055 (10,000 free); SSO users cost $0.015 on every plan. These are AWS's list rates for Cognito user pools. On your own AWS account AWS bills them to you; on a SaaSLayer-hosted account they are part of the hosted price, which is not decided.

  • Native sign-in means email or phone with a password, passkey or one-time code, and social providers.
  • SSO users are people who sign in through a SAML or OIDC connection. AWS bills them as federated users at the same rate on Lite and Essentials (50 free a month).
  • Turning SSO off returns the pool to Lite once every connection is deleted. Right before that deploy, the login domains return to the classic hosted UI.

Token claims (Lite by default)

By default (V1 claims, which a Lite pool and SSO's Essentials pool both use), only the ID token carries SSO claims, as flat strings:

{
  "sso_connection": "conn_0123456789abcdef0123",
  "sso_tenant": "t_acme",
  "sso_groups": "[\"admins\",\"eng\"]",
  "sso_groups_truncated": "false"
}
  • Read them with a reader, never by hand. Use readSsoClaims from @saaslayer/js (or @saaslayer/permissions/server). Truncated or unavailable groups read as groups: null, never as an empty list. A malformed or newer claim set fails closed (sso_claims_malformed, sso_claims_newer_than_reader).
  • Group caps. A token holds at most 50 groups and 2,048 bytes of group list. Beyond that it is marked truncated; the stored set stays complete.
  • Access-token claims (V2). Claims on access tokens need a paid Cognito tier and an explicit opt-in: user-service.UserPoolTier=ESSENTIALS or PLUS, then user-service.PreTokenClaimsVersion=V2_0. This adds a nested sso object to the access token. SSO's own move to Essentials keeps V1 claims, so turning SSO off can return to Lite.
    • On your own AWS account, the tier change needs a --reason, because it changes what AWS bills.
    • On a SaaSLayer-hosted account, the tier is commercially controlled. No hosted plan includes it yet, because pricing is not decided.

When a removal takes effect

Cognito can't revoke an issued token for a verifier that only checks the JWT. SaaSLayer refuses removals online through the live checks. A verifier that only checks the JWT offline sees them only when the token expires.

What happenedRefreshuser-service API and POST /api/auth/statusPermissions (A: HTTP mode, authorizer, direct mode with accountStatus)JWT-only verifier
SCIM active:false or DELETErefused at oncenext requestnext checkuntil exp (default ≤ 5 min)
Connection disabled or deletedrefused at oncenext requestnext checkuntil exp
Session cap reachedrefused (Cognito, at the cap fixed at sign-in)refused from auth_time + caprefused from auth_time + cap (SSO_SESSION_EXPIRED)until exp
Credential signed out (admin sign-out, MFA policy switched to saaslayer)refusednext requestnext checkuntil exp
Domain enforcement cutover (native sessions)refusednext requestnext check, when the verifier has the trusted-clients registryuntil the native token's exp
Person disabled only in the identity provider, with no SCIMnot refusednot refusednot refusednot refused

The last row matters: without SCIM, SaaSLayer never hears about a deprovisioning upstream. The person's session runs until its cap (12 hours by default), and a JWT-only verifier accepts their token until exp after that. Use SCIM where immediate deprovisioning matters.

What a deprovisioning does is the connection's --deprovision policy:

PolicyEffect
disable_and_remove_from_org (default)Signs out the connection's credential (and native sign-in when the domain is enforced), removes the memberships and roles this connection's source granted, and revokes the person's API keys in each org they no longer belong to (A, C).
remove_from_org_onlyRemoves the org access without a sign-out.
disableSigns the person out and keeps the org membership.

A SCIM DELETE always removes the org access. The account itself is kept for its other orgs and sign-in methods.

  • Setup link. The company's IT admin configures the connection through a setup link. Each connection has one link at a time, valid for 7 days by default (1–168 hours). Issuing a new link ends the old one and every session it opened, as does activating the connection.
  • Hosted pages. The link opens the instance's hosted setup page (<user-service API base>/sso-setup#setup=…). The token stays in the URL fragment and is cleared from the address bar.
  • Hosted settings page. Tenant admins who don't use your embedded settings get the hosted settings page (/sso-settings#session=…), opened with a management session.
  • Dashboard tiles. Okta and Entra dashboard tiles start a fresh SP-initiated sign-in; see SSO dashboard tiles.

Lifecycle events

With saaslayer users hooks set ssoLifecycle --url <your endpoint>, the instance sends signed webhook events. Each event carries ids only (connectionId, and suid where a person is involved):

  • sso.user.deactivated, sso.user.reactivated, sso.user.deleted;
  • sso.groups.changed;
  • sso.connection.activated, sso.connection.disabled, sso.connection.deleted;
  • sso.enforcement.cutover;
  • sso.certificate.expiring (SAML signing certificate at 90, 30, 7 and 1 days, and when it expires);
  • sso.domain.unverified.

Deliveries are retried for 24 hours with the same webhook-id, then dead-lettered.

Not in this release

  • SAML single logout.
  • Google Workspace directory sync. Google connections sign in only.
  • Per-tenant branding of the identity-provider redirect.
  • Nested groups, and SCIM OAuth client credentials. SCIM uses bearer tokens.
  • Instant deprovisioning from the identity provider without SCIM (see the table above).
  • An automatic Cognito tier upgrade.
  • Parity with every WorkOS or Clerk feature. These guides list what is supported; anything not listed is not.