---
title: SSO with Users and Permissions (combo A)
description: Use SSO with SaaSLayer Users for sign-in and SaaSLayer Permissions for access.
canonical_url: 'https://saaslayer.com/docs/users/sso-combo-a/'
last_updated: '2026-11-22T22:46:11-08:00'
---
# SSO with Users and Permissions (combo A)

You run **user-service and permissions-service**. People sign in through their company's identity provider via
user-service. Permissions decides what they may do, from the company's groups and the mappings you approve. Read
[Enterprise SSO](https://saaslayer.com/docs/users/enterprise-sso) for the concepts first.

> Pre-release; names are provisional until the SSO naming review; pricing is not decided. See the status note in
> [Enterprise SSO](https://saaslayer.com/docs/users/enterprise-sso).

## 1. Turn SSO on

```bash
saaslayer deployment settings set --env prod --set user-service.EnableSso=true --reason "enterprise SSO"
```

The deployer wires the two services for you. Permissions-service gets user-service's trusted-clients source, so it
accepts tokens from each connection's app client the moment the connection activates. Its user-service key also gains
the one permission that applies SSO group states. Nothing else changes for people who already sign in.

## 2. Create and set up a connection

As the deployment owner (`saaslayer login --deployment <dep_id|env>`):

```bash
saaslayer sso create --tenant <orgId> --protocol saml --issuer http://www.okta.com/exk123abc \
  --metadata-url https://acme.okta.com/app/exk123abc/sso/saml/metadata --domain acme.com --scim on
saaslayer sso status <connectionId>
```

Then follow the identity provider's recipe in [Provider setup](https://saaslayer.com/docs/users/sso-provider-setup). Or hand the company's IT admin a
setup link (it opens the instance's hosted setup page):

```bash
saaslayer sso link issue <connectionId> --to-ssm /acme/sso-setup-link
```

The link is written to SSM or a file and never printed.

Verify the domains, take a SCIM token, and activate:

```bash
saaslayer sso domains verify <connectionId> acme.com
saaslayer sso scim issue <connectionId> --to-ssm /acme/scim-token
saaslayer sso activate <connectionId>
```

**Who may manage a connection.** Org owners of the connection's tenant org may read and manage it, issue its setup link
and read its audit trail by default. Only the deployment owner creates connections and sets the owner-only fields
(`tenant`, `orgIds`, `managerGroup`, `breakGlass`, `deletePolicy`). Admins of other orgs see nothing of it. The console's
SSO page offers the same operations.

## 3. Map groups to orgs and roles

Mappings live in Permissions, per connection source (`sso:<connectionId>`) and tenant org, so these commands call the
deployment's permissions API: pass its base URL with `--api-base`.

1. **The deployment owner sets the ceiling:** the orgs the connection may add people to, and any privileged roles its
   rules may grant (owner parts, admin roles):

   ```bash
   saaslayer sso mappings ceiling <connectionId> --tenant <orgId> --deployment <dep_id> \
     --api-base https://<permissions-api-base> --allow-org <orgId> --approve-role <orgId>/billing-admin
   ```

2. **The tenant's admin sets the rules** within the ceiling. The file holds `{ "rules": [...], "defaultGrant": ... }`,
   and the CLI sends it at the revision it read:

   ```json
   {
     "rules": [
       { "group": "Engineering", "orgId": "org_acme", "roleIds": ["developer"] },
       { "group": "Finance", "orgId": "org_acme", "roleIds": ["billing-admin"] }
     ],
     "defaultGrant": { "orgId": "org_acme", "roleIds": ["viewer"] }
   }
   ```

   ```bash
   saaslayer sso mappings rules <connectionId> --tenant <orgId> --deployment <dep_id> \
     --api-base https://<permissions-api-base> --file rules.json
   saaslayer sso mappings get <connectionId> --tenant <orgId> --deployment <dep_id> \
     --api-base https://<permissions-api-base>
   ```

What the mappings do:

* **The group key.** `group` is the group's key as the connection's group authority reports it. From sign-in, it is
  the value in the provider's groups claim or attribute (Okta group names; Entra object ids). From SCIM, it is the
  Entra object id or the Okta group name. A matched rule grants its roles in its org.
* **The default.** `defaultGrant` applies only to people no rule matches. It never applies to people with incomplete
  groups, or to Google connections (no group authority).
* **The ceiling is enforced.** A role above the ceiling is refused (`GROUP_MAPPING_ROLE_ABOVE_CEILING`), and so is an
  org outside the allowlist.
* **Edits apply to everyone.** Every mapping edit recomputes the connection's people.
* **Source-owned grants.** Memberships and roles granted this way belong to the source. A manual grant of the same role
  is kept beside it.

Groups count from the connection's first activation (sign-in authority, every provider except Google). With SCIM, they
come from the directory once you run `saaslayer sso scim sync-complete <connectionId>` after the first full push; see
[Groups](https://saaslayer.com/docs/users/enterprise-sso#groups-and-who-owns-them).

## 4. Check permissions

**HTTP mode** (the Permissions API, your API Gateway authorizer, or `createAuthz` with `mode: 'http'`) needs nothing new.
Permissions asks user-service for the live status of every SSO session (and of native sessions in a domain under
enforcement) on every check. A removal is refused at the next check.

* **Removed:** `401 SSO_STANDING_INACTIVE`.
* **Past the session cap:** `401 SSO_SESSION_EXPIRED`.
* **Status unreadable:** `503 SSO_STANDING_UNAVAILABLE`.

**Direct mode** (`@saaslayer/permissions/server` reading the permissions table) must be configured for SSO:

```js
const { createAuthz } = require('@saaslayer/permissions/server')

const authz = createAuthz({
  publishableKey: process.env.SAASLAYER_PUBLISHABLE_KEY,
  trustedClients: { endpoint: 'https://<user-service API base>/api/sso/trusted-clients', apiKey: process.env.TRUSTED_CLIENTS_KEY },
  accountStatus: { endpoint: 'https://<user-service API base>/api/auth/status', apiKey: process.env.TOKEN_STATUS_KEY },
  permissions: { mode: 'direct', tableName: process.env.PERMISSIONS_TABLE_NAME, fallbackApiBase: 'https://<permissions API base>' },
})
```

* **`trustedClients`** admits each active connection's app client. It reads the registry at most every 60 seconds.
* **`accountStatus`** asks the live status before every decision for an SSO session. Without it, direct mode denies
  every SSO session (`current_state_unconfigured`).
* **Release declaration.** Declare your reader with `currentState: 'account-status'` (`@saaslayer/permissions` 0.3.0 or
  later).
* **The keys.** Both are verifier keys the deployment owner creates. They are written to SSM (or a 0600 file), never
  printed:

  ```bash
  saaslayer users verifier-keys create --purpose trusted-clients --to-ssm /acme/trusted-clients-key
  saaslayer users verifier-keys create --purpose token-status --to-ssm /acme/token-status-key
  ```

  Each scope allows at most 2 active keys; `saaslayer users verifier-keys revoke <keyId>` refuses a key from its next request.

**Authorizer caching:** an API Gateway authorizer with result caching would keep allowing a removed SSO session until the
cache entry expires. Set the authorizer cache TTL to 0 for routes SSO sessions call.

## 5. Sessions for agents and delegated tokens

By default an SSO session can't mint Permissions session tokens (`POST /sessions/assume`, delegated sessions, access
request exchange): `403 SSO_SESSION_MINT`. With `saaslayer sso update <connectionId> --delegated-tokens short_lived`,
minted tokens last at most 15 minutes and never past the SSO session's deadline. They are re-checked live on every use,
so a SCIM deactivation, a sign-out or a switch back to `blocked` refuses them at their next check.

## 6. Deprovisioning and its clocks

With SCIM, `active:false` or `DELETE` is refused at the next user-service request and the next permission check. The
connection's `--deprovision` policy then removes the memberships, roles and org API keys its source granted. The removal
reaches Permissions through a durable delivery, usually within seconds; a sweep retries within about 5–10 minutes. Until
then the live status check already refuses the SSO session. See [When a removal takes effect](https://saaslayer.com/docs/users/enterprise-sso#when-a-removal-takes-effect).

## What to know

* **Default org.** An SSO person's default org hint (`custom:soid`) is checked against their memberships on every
  issuance. They may have no default org until a mapping admits them to one.
* **Personal orgs.** A new SSO person gets a personal org unless the connection sets `--create-personal-org off`.
* **The audit trail.** `saaslayer sso audit <connectionId>` (or `GET /api/sso/connections/{connectionId}/audit`)
  records every connection change, SCIM write, sign-in result and setup-link use. It is redacted: ids only, never a
  token, an assertion or an email.
