External identity exchange¶
The exchange is the one operation that turns an identity your provider issued into an identity Xratu recognises. It is how you get your first token, and it is the only path to one.
What it does¶
You present a provider-issued token. The control plane resolves an actor from it, and returns an Xratu-issued token carrying that actor.
flowchart LR
P["Your identity provider"] -->|"you obtain a token"| T["External token"]
T -->|"POST /v1/auth/exchange"| CP["Control plane"]
CP -->|"resolves actor,<br/>issues Xratu token"| X["access_token"]
X --> U["Stored on your CLI profile"]
The provider-issued token is used once, at the exchange. Everything afterwards uses the Xratu token.
The request¶
| Field | Type | Default | Meaning |
|---|---|---|---|
external_token |
string | required | The token your provider issued |
provider |
string | inferred | gcp, aws, azure or oidc |
ttl_seconds |
integer | 3600 |
Requested lifetime of the issued token |
provider is optional because the control plane infers it from the token's
issuer when it is omitted. ttl_seconds has a floor: a value below 300 is
raised to 300.
The response¶
{
"access_token": "...",
"token_type": "bearer",
"actor_id": "user:alice@acme.example",
"provider": "gcp"
}
The issued token carries the actor as its subject, the provider, and the claims
the actor was resolved from: email, sub, iss and groups.
Doing it from the CLI¶
| Flag | Effect |
|---|---|
--provider |
The provider hint, gcp, aws, azure or oidc |
--external-token |
The token you obtained, required |
--ttl-seconds |
Requested lifetime, default 3600 |
--set-token |
Persists the issued token to the active profile |
--set-actor |
Stores the returned actor_id on the profile |
--set-actor stores local metadata only. Effective request identity always
comes from the token, so the stored actor is for your reference and grants
nothing.
Obtaining TOKEN in the first place happens outside Xratu. See
Token acquisition.
Clear a stale token first¶
The exchange is an ordinary request, and a stale token on the profile will be sent with it. Clear it before exchanging:
What the control plane checks¶
Three conditions, in order, and each has a distinct failure.
1. Cloud token trust must be enabled. If it is not:
Inspect the posture with xratu auth config-get. On a finalized deployment this
setting is locked, so enabling it is a break-glass act. See
The authentication model.
2. The external token must resolve to a real actor. The control plane verifies it as an external cloud token, which means the issuer must be allowed and the audience accepted. If resolution yields the system actor, or the token was not recognised as an external one at all:
For a built-in provider this usually means the token is not what you think it
is: a user credential rather than a service-account identity token, or an
audience that does not match. For oidc it means the issuer is not in the
configured allowlist, since generic OIDC has no built-in trust. See
Supported identity providers.
3. The email domain must be allowed, when a domain restriction is
configured. A token outside it is rejected with email_domain_not_allowed.
Verify the result¶
Three things should be true: actor_id is no longer system,
auth_context.mode is token, and auth_context.token_provider names the
provider you exchanged against.
If whoami still reports system after a successful exchange, the CLI is not
sending the issued token. Confirm the profile holds it and that the profile is
active. See Configure a CLI profile.
What the exchange leaves to other steps¶
Authentication happens with your provider. You arrive holding a token.
The actor is derived from claims on every request. Mapping an external principal onto a different internal actor is a separate, explicit configuration. See Actors.
Permissions come from role bindings. A freshly resolved actor can authenticate and create its first organisation, which binds that actor as owner and is the source of every right that follows.
To run it end to end, see Exchange an external identity for an Xratu token.