Skip to content

Principal and group mappings

Two mapping layers sit between what your identity provider asserts and what Xratu authorises. A principal mapping redirects an external principal onto an internal actor. A group mapping adds an internal group name alongside the groups the provider asserted.

Where they are applied

flowchart TB
  T["External token verified<br/>issuer and audience accepted"] --> D["Email domain check"]
  D --> A["Actor derived from claims"]
  D --> G["Groups read from claims"]
  A --> PM{"Principal mapping for<br/>provider, issuer, subject?"}
  PM -->|yes| MA["Mapped actor id"]
  PM -->|no| DA["Derived actor id"]
  G --> GM["Group mappings resolved"]
  GM --> EG["Effective groups =<br/>claim groups + mapped groups"]
  MA --> R["Request principal set"]
  DA --> R
  EG --> R

Both layers resolve when an external cloud token is verified, which is the path an exchange runs. The resulting actor and effective groups are written into the Xratu token that the exchange issues, so a mapping added afterwards applies at the next exchange rather than to a token already held.

Principal mappings

A principal mapping is keyed by provider, issuer and subject, and names the actor to use.

xratu auth principal-map-create \
  --provider oidc \
  --issuer https://login.acme.example \
  --subject 107107332738596210843 \
  --actor-id user:alice@acme.example
xratu auth get principal-mappings --provider oidc
{
  "status_code": 200,
  "body": {
    "items": [
      {
        "mapping_id": "2f61b8d0c47a4e9bb3d5107ac9e28f41",
        "provider": "oidc",
        "issuer": "https://login.acme.example",
        "subject": "107107332738596210843",
        "actor_id": "user:alice@acme.example",
        "enabled": true,
        "metadata": {},
        "created_by_actor": "user:alice@acme.example",
        "created_at": "2026-09-14T09:12:44Z",
        "updated_at": "2026-09-14T09:12:44Z"
      }
    ]
  }
}
Field Meaning
provider oidc, gcp, aws or azure, lowercased
issuer The issuer this mapping applies to, lowercased
subject The external sub value, matched exactly
actor_id The internal actor the request runs as
enabled A mapping is consulted while true

A mapped actor replaces the derived one entirely, so bindings are written against actor_id and the external subject appears nowhere in authorisation.

Group mappings

A group mapping is keyed by provider, issuer and the external group value, and names the internal group.

xratu auth group-map-create \
  --provider oidc \
  --issuer https://login.acme.example \
  --external-group acme-platform-eng \
  --internal-group platform-engineering
xratu auth get group-mappings --provider oidc
Field Meaning
provider oidc, gcp, aws or azure, lowercased
issuer The issuer this mapping applies to, lowercased
external_group The group claim value, matched lowercased
internal_group The group name bindings are written against
enabled A mapping is consulted while true

Mapped groups are added to the groups the token asserted, and the principal set is built from the union. A binding on either name authorises the request, so renaming a group in your directory is absorbed by adding a mapping.

Bind against the internal name:

xratu bind role developer --to group:platform-engineering --organization acme

Issuer matching

Each lookup runs twice, and the first hit wins. It first consults the mapping whose provider and issuer both match the token, and failing that the one whose provider matches and whose issuer is empty.

A mapping created with --issuer applies to one issuer. A mapping created without it applies to every issuer of that provider, which is how a single gcp or azure rule covers a whole provider.

Properties

Group names are compared lowercased. External group values are lowercased when the claims are read, and again when a mapping is stored. Internal names reach the principal set with the group: prefix.

A mapping is on or off. --disabled creates one that is recorded and not consulted, and auth principal-map-delete or auth group-map-delete removes one by mapping_id.

Both layers are optional. With neither configured, the derived actor and the asserted groups are used as they arrive.

Related: Actors and RBAC covers how the principal set becomes a decision, and External identity exchange covers the path these layers run on.