# Group-restricted OIDC login

**Last updated:** 2026-11-21T10:44:38-03:00 (UTC-3)

Only people in the right IdP groups get into the console. With `oidc_group_policy`, the gateway reads the groups claim from the ID token and denies login to anyone who is not on the list. It is one more gate: the local user binding is still required, and the group does not create a user, grant a role or change teams.

## How to turn it on

On top of a complete [SSO](/docs/features/oidc/) configuration:

```yaml
features:
  oidc_group_policy: true        # boot; requires oidc_login
admin:
  oidc:
    session_epoch: groups-reviewed-v1
    group_policy:
      claim: groups
      match: any                 # or all
      required_groups: [/gateway-users, /gateway-operators]
```

| Field | Rule |
| --- | --- |
| `session_epoch` | Required. An identifier of 1 to 64 characters (`A-Z`, `a-z`, digits, `_`, `-`); see [rollout](#rollout) |
| `admin.oidc.group_policy.claim`, `admin.oidc_providers[].group_policy.claim` | Literal name of a top-level claim, 1 to 64 characters. No JSONPath: a dot is part of the name. Identity, protocol and roles claims are reserved |
| `admin.oidc.group_policy.match`, `admin.oidc_providers[].group_policy.match` | `any` (one group is enough) or `all` (all of them) |
| `admin.oidc.group_policy.required_groups`, `admin.oidc_providers[].group_policy.required_groups` | 1 to 20 unique groups, up to 256 bytes each |

The comparison is **exact**: case-sensitive, with no prefix, regex or hierarchy. Use the full path the IdP emits (in Keycloak, `/gateway-users`).

In the IdP, emit the groups claim **in the ID token**. In Keycloak, use the group membership mapper and check the names.

**Settings & sources** shows whether the policy is on and whether it needs a rollout. The policy does not appear in logs, exports or public discovery.

## How it works

- The claim must be a list of up to 128 strings, with no repeats. Missing, null, a bare string, an object or a mixed list deny the login.
- Signature, issuer, audience, nonce and the local binding are verified before the groups.
- A failure returns the generic login error, without exposing the groups.
- **The check happens at login.** Removing someone from the group in the IdP does not end an open session. For that, use [backchannel logout](/docs/features/oidc-logout/), deactivate the local user or require a new login.

## Rollout

1. In a test environment, check the claim the IdP actually emits, without logging ID tokens.
2. Choose a **new** `session_epoch` and keep a local administrative access path for emergencies.
3. Publish the policy, the flag and the same epoch on all replicas.
4. Require a new login and confirm acceptance and denial with test users.
5. To roll back, advance or preserve the epoch deliberately. Never go back to an old epoch while cookies from that time may still be valid.

Changing the policy or the epoch invalidates flows and sessions created under the previous configuration.

## Limits

- It does not query an external directory: only the token's claim. Google Workspace groups and nested roles have not been validated.
- A group does not become a role or a team. For teams coming from the IdP, use [SCIM groups](/docs/features/scim/#groups).
- The group policy never creates a user. [JIT provisioning](/docs/features/jit-provisioning/) can, for allowlisted identities, after this policy admits the login. [SAML](/docs/features/saml/) login has no group restriction.

## See also

- [SSO](/docs/features/oidc/) and [logout](/docs/features/oidc-logout/).
- References: [OpenID Connect Core](https://openid.net/specs/openid-connect-core-1_0.html), [Keycloak protocol mappers](https://www.keycloak.org/docs/latest/server_admin/index.html).

## Typed policy and rollout

`match` is required in a group-policy block and accepts only `any` or `all`; it has no implicit choice. The same typed backend constraint is used during configuration validation. A supplied group-policy object is validated even when its feature is disabled, while general OIDC trust retains its existing flag-dependent validation. Group names, claim restrictions and subject-to-local-user mapping remain separate rules. This adds no group-policy editor, applied-value summary or role grant; update the boot configuration and roll it out using the existing epoch procedure.
