Skip to content
Workforce IdentityMarkdown

Transaction tokens

Short-lived tokens that carry one request's identity, purpose and context through your internal services, never the caller's own token.

AvailableAPIOAuth Transaction Tokens (draft), RFC 8693

A transaction token carries one request through your internal services without carrying the caller’s token. The first service a request reaches trades the caller’s access token for a short JWT that names the transaction, the user or agent it is for, its purpose and the service that asked. Every service further in reads who the call is for and why, and none of them can act as the caller.

Use it in systems with many internal hops, where passing the original token along is a risk, or wherever internal services need to know who a call is for and why without being able to act as the caller.

  • Who can do it: a realm administrator (a group holding RealmOwner) names the trust domain and marks each workload; RealmViewer can read both. The workloads then ask for transaction tokens themselves.
  • Where: today this is done through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: each workload that asks can sign a private_key_jwt assertion, or holds a JWT-SVID (Workload identity).

The first service a request reaches is the workload. It exchanges the access token at the realm for a transaction token, valid only inside your trust domain: the name you give the set of services that share these tokens. Your internal services pass it along, in the Txn-Token header as the standard describes, and each one checks it against the realm’s published keys. The checking is your services’ own: the realm issues and replaces transaction tokens, and the gateway doesn’t read them.

1. The workload asks, authenticating with its key, and naming the trust domain as the audience, the purpose as the scope, and the access token it received as the subject_token:

Terminal window
curl https://foobar.cvyuh.com/oauth2/token \
-d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
-d requested_token_type=urn:ietf:params:oauth:token-type:txn_token \
-d audience=orders.example.internal \
-d scope=orders.read \
-d subject_token=eyJ… \
-d subject_token_type=urn:ietf:params:oauth:token-type:access_token \
--data-urlencode 'request_details={"orderId":"A-1042"}' \
--data-urlencode 'request_context={"ip":"203.0.113.7"}' \
-d client_id=checkout-api \
-d client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
-d client_assertion=eyJ…
{
"access_token": "eyJ…",
"issued_token_type": "urn:ietf:params:oauth:token-type:txn_token",
"token_type": "N_A",
"expires_in": 60
}

The token is in access_token, as token exchange returns every token, but it isn’t an access token: token_type is N_A.

2. The token is a JWT signed RS256, with the header typ txntoken+jwt:

{
"iss": "https://foobar.cvyuh.com/oauth2",
"aud": "orders.example.internal",
"txn": "9d3f6c2a-71b4-4e0a-8a55-3c2e1f9b7d60",
"sub": "2b7e4f10-8c3a-4d1e-9f6b-5a0c7d2e9b13",
"scope": "orders.read",
"req_wl": "checkout-api",
"tctx": { "orderId": "A-1042" },
"rctx": { "ip": "203.0.113.7" },
"iat": <unix time>,
"exp": <iat + 60>,
"jti": "5c1e8a4b-2f7d-4b19-a0c3-6e9d4f2a8b15"
}
ClaimWhat it says
txnThe transaction
sub, actThe subject, and the chain of who acts for whom, from the access token
scopeThe purpose
req_wlThe workload that asked: its SPIFFE ID when it signed in by its SVID, else its client id
tctxThe details the workload sent in request_details
rctxThe context the workload sent in request_context

3. To swap, a service further in sends the transaction token as the subject_token, with subject_token_type=urn:ietf:params:oauth:token-type:txn_token, the same audience, and a scope no wider. It gets a narrower token for its own calls.

These steps use the admin API; Call the API shows how to get a session.

  1. Name your trust domain in txnTokenTrustDomain and add the token-exchange grant to the realm’s grantTypes, with PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings. Read the realm’s settings first with GET on the same address, and send back the whole list with the new value added: a list you send replaces the realm’s list.
  2. On each workload’s client (https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client), set issuesTxnTokens, the token-exchange grant, and tokenEndpointAuthMethod private_key_jwt.
WhereSettingWhat it does
RealmtxnTokenTrustDomainYour trust domain’s name. Absent, no transaction token is issued
RealmtxnTokenLifetimeSecs60 by default, 300 at most
Realm and workloadgrantTypes include urn:ietf:params:oauth:grant-type:token-exchangeOff by default
Workload appissuesTxnTokens, with tokenEndpointAuthMethod private_key_jwtLets it ask (default off)
Workload appassertionTrust spiffe, spiffeIdIt proves itself by its SVID, registers no key, and is named by its SPIFFE ID
Setting or limitDefaultRange
txnTokenTrustDomainnone: no transaction tokensyour trust domain’s name
txnTokenLifetimeSecs60up to 300, and never past the token it came from
request_details, request_contextnonea JSON object each, at most 4,096 bytes
issuesTxnTokens on a clientoffper client, private_key_jwt only
SymptomCauseFix
invalid_targetThe realm names no trust domain, or audience isn’t exactly itSet txnTokenTrustDomain, and send it as audience
unauthorized_clientThe client isn’t marked issuesTxnTokensMark it, with private_key_jwt
invalid_request with a valid access tokenIt wasn’t issued to this workload or for an API it serves, or no scope was sentExchange the token your workload received, and send scope
A downstream service refuses it as an access tokenIt isn’t oneVerify it as a transaction token, against the realm’s keys

Every request, issued or refused, is a TOKEN_EXCHANGED record keyed by the user or agent the transaction is for, with the access token’s id as its parent and, for a refusal, its reason. It’s on the subject’s trail (Read a user’s or agent’s trail) and in Audit → Authentication.

  • It is off until you name your trust domain. The token’s aud is exactly that name, and a token for any other domain is refused.
  • Only a workload you mark asks: an app with issuesTxnTokens, which must prove itself with a key (private_key_jwt): one registered on it, or its JWT-SVID under assertionTrust spiffe (workload identity).
  • The access token must be meant for the workload (issued to it, or for a resource it serves), and still active.
  • The purpose is never wider than the access token’s scope. A scope must be sent, and an access token with no scope can’t buy one. The access token must still be active as introspection judges it, which includes its governed scopes still being granted. No new entitlement or issuance-policy decision is made for the transaction token itself.
  • No actor token. The chain of who acts for whom comes from the access token, and an actor_token is refused.
  • The caller’s token is never inside it, nor its app or key binding. request_details and request_context are each a JSON object of at most 4 KiB (4096 bytes).
  • It is short-lived: a minute by default, at most five, and never longer than the token it came from. Revoking that token doesn’t revoke a transaction token already issued from it, which ends at its own exp. Workloads verify it offline against the realm’s keys, so there is nothing they could ask.
  • A swap keeps the transaction. The transaction, subject, trust domain and details stay the same. The purpose may only narrow, and the context may gain entries but never change one. Each workload that asked is kept in order (req_wl_chain). A swapped token never outlives the one it replaced, and an expired one isn’t swapped.
  • It is never an access token. Presented as one, it is refused, and introspection answers it inactive.
  • Every exchange is recorded. Issued or refused, it is on the subject’s audit trail.
ErrorWhen
unauthorized_clientThe client isn’t a workload marked issuesTxnTokens
invalid_targetThe realm names no trust domain, or audience isn’t it
invalid_scopeA scope beyond the subject token’s
invalid_requestNo scope; an actor_token is sent; request_details or request_context isn’t a JSON object or is over 4096 bytes; the subject token is missing, invalid, not meant for this workload, inactive or expired; on a swap, the transaction token is for another trust domain, or a request_context entry would change one it holds