# Provisioning with SCIM

**Last updated:** 2026-11-21T09:54:10-03:00 (UTC-3)

The IdP (Entra ID, Okta, authentik, Keycloak with an extension) creates and deactivates console users on its own. When someone leaves the company and is deactivated in the IdP, their console session drops on the next request and that person's keys stop working. With SCIM groups, teams can also come from the IdP, once an admin links each group to a team.

| Resource | Flag |
| --- | --- |
| Users (`/scim/v2/Users`) | `scim` |
| Groups linked to teams (`/scim/v2/Groups`) | `scim_groups` (requires `scim` and `team_management`) |

**No SCIM attribute grants a role.** `roles`, `title` and similar attributes are accepted and discarded. Roles and teams are decided in the console.

## How to enable it

```yaml
features:
  console_users: true
  granular_rbac: true   # the user role only exists with granular RBAC
  scim: true
  scim_groups: true     # optional
admin:
  scim_token_sha256_env: GATEWAY_SCIM_SHA256
```

- The IdP authenticates with `Authorization: Bearer <token>`. The gateway stores only the token's SHA-256: put its hex digest in `GATEWAY_SCIM_SHA256`, the variable `admin.scim_token_sha256_env` names in the shipped YAML (or in a file, with `GATEWAY_SCIM_SHA256_FILE`). It must be different from the admin and viewer tokens.
- The flag can be turned on and off without a restart, in **Settings & sources**. When it is off, the routes respond 404.
- In the IdP, point the base URL to `https://gateway.example.com/scim/v2`.

## Users

| Route | Support |
| --- | --- |
| `GET /scim/v2/ServiceProviderConfig` and `/ResourceTypes` | Yes |
| `GET /scim/v2/Users` | Filters `userName eq "..."` and `externalId eq "..."`; `startIndex`/`count` up to 200 |
| `POST /scim/v2/Users` | Creates an active user, with the `user` role and **no teams** |
| `GET /scim/v2/Users/{id}` | Yes |
| `PATCH` / `PUT /scim/v2/Users/{id}` | Only `active` (`true`/`false`, or Entra ID's `"True"`/`"False"`) |
| `DELETE /scim/v2/Users/{id}` | Deactivates; history and audit are kept |

Any other filter is refused with `invalidFilter`, because an ignored filter would return every user.

- **`externalId` = the IdP's `sub`.** On [OIDC](/docs/features/oidc/) login, the SCIM link wins over the `subject_users` map, which can stay empty.
- A provisioned user can only sign in through SSO: their local token is random and is never returned.
- **Without a team, login is denied.** Assign a team in the console or use groups.
- **Deactivate** (`active=false` or `DELETE`): sessions drop on the next request, and the keys the user [owns](/docs/features/identity-ownership/) are refused.
- **Reactivate** (`active=true`): only users deactivated through SCIM come back, with the same role, teams and keys. Keys revoked by an admin and old sessions stay invalid. A user deactivated by an admin in the console gets `400 mutability`. The keys work again at once on the replica that handled the request, and within 5 seconds on the others (a replica briefly remembers a key it found unusable).
- `userName` and `externalId` are unique and immutable; creating again returns `409 uniqueness`, including for simultaneous creations.

In the console, **Console users** marks users managed by the IdP with "Provisioned by SCIM".

## Groups

With `scim_groups`, the IdP manages groups and members at `/scim/v2/Groups` (list with the `displayName eq` and `externalId eq` filters, create, read, `PUT`, `PATCH` of members and name, delete), in the Entra ID, Okta and authentik formats.

The effect is decided in the console:
1. The group arrives from the IdP and is stored **without granting anything**.
2. A global admin links the group to a team in **Console users → SCIM groups** (or `PUT /api/v1/admin/scim-groups/{id}/team`).
3. From then on, the group's members are **members** of that team. A group never grants the admin role.

- Removing someone from the group in the IdP revokes access immediately, without touching teams assigned by hand.
- Teams assigned by hand take precedence over group teams; an `admin` membership only exists when assigned by hand.
- A group does not bring into the team a user created by hand in the console (`400 invalidValue`).
- A group links to one team.

## Audit

Creation and deactivation go into the identity audit with `actor = scim` and the call's `X-Request-Id`.

## Tested with authentik 2025.10

With authentik's native SCIM client and the default user and group mappings:
- the created user arrived through `POST /Users`, with `externalId` equal to the OIDC provider's `sub`;
- login only worked after the user had a team;
- deactivating in authentik dropped the open session (401 on the next request), and reactivating restored the role, team and keys;
- the group arrived and only granted access after it was linked; removing and adding members in authentik revoked and granted access immediately.

Things to watch for in authentik:
- it rejects emails on reserved domains (`.test`, `.example`) before calling the gateway;
- it does not propagate group deletion: remove the members or unlink the group in the console before deleting it;
- without `scim_groups`, remove the group mapping, or the sync fails on `/Groups` (404).

## Limits

- No Bulk, sorting, ETag, password or nested groups.
- SCIM does not create users on first login; that is [JIT provisioning](/docs/features/jit-provisioning/) (`federated_jit`), where an administrator approves each new federated user. SCIM-provisioned users can sign in with [OIDC](/docs/features/oidc/); [SAML](/docs/features/saml/) needs an explicit NameID binding.
- Entra ID and Okta have not been connected; the tests use requests in their formats.

## Admin API routes

Every route below needs a console session or an admin Bearer token, the role's permission and, for writes, the `X-CSRF-Token` header; the full contract is in the [API reference](/docs/api/).

| Route | What it does |
| --- | --- |
| `GET /api/v1/admin/scim-groups` | The groups the identity provider pushed, with their team binding |

## See also

- [SSO](/docs/features/oidc/).
- [Access control](/docs/features/access-control/).
