Mandate · Guide
CIBA authorization server
Available on Pro, Growth and Enterprise
Provenance implements OpenID Connect CIBA core (Client-Initiated Backchannel Authentication) in poll and ping modes, with Rich Authorization Requests (RFC 9396) of type provenance_action.
A client that already speaks CIBA asks a person to approve an action out of band. The account's policy decides whether a person is needed, and the person approves on their phone. The client then gets an intent token bound to that exact action, a receipt for each decision, and an id token describing the approver.
Every CIBA request goes through the same path as POST /v1/mandate/intents and POST /v1/mandate/assessments: the same policy, the same approval routing and delivery, the same decision ledger.
Before you begin: CIBA clients are on Pro and up (one client on Free). The person you ask must already be on the account: the owner, a member with the approver role or above, or an outside approver with an active link. Add an approval rule for the actions you'll send, as in policies.
- bc_authorizeclient authenticated, hint, authorization_details
- Policy decidesallow, approval to the person, or deny
- Poll the token endpointauthorization_pending, then tokens
1. Create an OAuth client
In the console, open Developers → OAuth clients and create a client, or call POST /. private_key_jwt is preferred: the client signs a short assertion with its own key (ES256 or EdDSA), and you register the public key inline or as a JWKS URL. client_secret_basic returns a secret once.
curl -s $PROVENANCE_API/v1/oauth/clients \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Payables",
"auth_method": "private_key_jwt",
"jwks_uri": "https://payables.acme.example/.well-known/jwks.json"
}'
const client = await fetch(`${process.env.PROVENANCE_API}/v1/oauth/clients`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ name: "Acme Payables", auth_method: "private_key_jwt", jwks_uri: "https://payables.acme.example/.well-known/jwks.json" }),
}).then((r) => r.json());
client = httpx.post(f"{api}/v1/oauth/clients", headers={"Authorization": f"Bearer {key}"}, json={
"name": "Acme Payables",
"auth_method": "private_key_jwt",
"jwks_uri": "https://payables.acme.example/.well-known/jwks.json",
}).json()
{
"id": "occ_01M6H9QK2B7Q9V3N8K4T6W1Y0R",
"object": "oauth_client",
"name": "Acme Payables",
"auth_method": "private_key_jwt",
"jwks_uri": "https://payables.acme.example/.well-known/jwks.json",
"jwks": null,
"allowed_scopes": ["openid"],
"allowed_details_types": ["provenance_action"],
"delivery_modes": ["poll"],
"status": "active"
}
The client's name is what the person sees on the approval page. In live mode, a developer's change to a client waits for an owner or admin.
2. Discover the endpoints
Clients read the endpoints from OpenID discovery (the same CIBA fields are in the RFC 8414 metadata at /.well-known/oauth-authorization-server).
curl -s $PROVENANCE_API/.well-known/openid-configuration
const config = await fetch(`${process.env.PROVENANCE_API}/.well-known/openid-configuration`).then((r) => r.json());
config = httpx.get(f"{api}/.well-known/openid-configuration").json()
The fields a CIBA client reads:
| Field | Value |
|---|---|
backchannel_ | Where to send the request |
backchannel_ | ["poll", "ping"] |
backchannel_ | false |
authorization_ | ["provenance_ |
token_ | Where to poll |
token_ | private_, client_ |
jwks_ | The keys that sign the access token and the id token |
3. Ask the person
POST /v1/oauth/bc_authorize is form-encoded. Authenticate the client, send scope=openid, exactly one hint, and the action in authorization_details:
| Field | What it is |
|---|---|
login_ | The person's email (the owner, a member or an outside approver), or the pairwise sub from an earlier id token |
id_ | An id token Provenance issued to this client (login_ takes the same) |
binding_ | Up to 64 characters, shown to the person on the approval page so they can match it to your app |
requested_ | Seconds the request may wait (default 600, at most 1800) |
authorization_ | A JSON array of 1 to 5 provenance_ objects |
Each provenance_action is decided as its own action and gets its own receipt:
| Field | What it is | Policy fact |
|---|---|---|
action_ | Required: what kind of action (pay_) | action_ |
description | Required: what the person reads | |
amount, currency | The amount and its ISO 4217 currency | transaction_, currency |
counterparty | Who the action is with | counterparty |
payload_ | The SHA-256 of your own exact payload | |
mandate_ | A grant the action runs under (the only detail then) | the grant's limits |
run_ | An agent-team run | the run facts |
The policy also reads oauth_client_id, so a rule can apply to one client.
curl -s $PROVENANCE_API/v1/oauth/bc_authorize \
-d scope=openid \
-d login_hint=ana@acme.example \
-d binding_message="Code 7Q4-K2" \
--data-urlencode 'authorization_details=[{"type":"provenance_action","action_type":"pay_invoice","description":"Pay invoice INV-1042 to Brindlecote Supplies for $2,400","amount":2400,"currency":"USD","counterparty":"brindlecote.example"}]' \
-d client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
-d client_assertion=$CLIENT_ASSERTION
const start = await fetch(`${process.env.PROVENANCE_API}/v1/oauth/bc_authorize`, {
method: "POST",
body: new URLSearchParams({
scope: "openid",
login_hint: "ana@acme.example",
binding_message: "Code 7Q4-K2",
authorization_details: JSON.stringify([
{ type: "provenance_action", action_type: "pay_invoice", description: "Pay invoice INV-1042 to Brindlecote Supplies for $2,400", amount: 2400, currency: "USD", counterparty: "brindlecote.example" },
]),
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
client_assertion: clientAssertion, // see "A complete client" below
}),
}).then((r) => r.json());
start = httpx.post(f"{api}/v1/oauth/bc_authorize", data={
"scope": "openid",
"login_hint": "ana@acme.example",
"binding_message": "Code 7Q4-K2",
"authorization_details": json.dumps([{"type": "provenance_action", "action_type": "pay_invoice", "description": "Pay invoice INV-1042 to Brindlecote Supplies for $2,400", "amount": 2400, "currency": "USD", "counterparty": "brindlecote.example"}]),
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"client_assertion": client_assertion, # see "A complete client" below
}).json()
{ "auth_req_id": "cba_Vq7m2KxT9nB4wC1zD3fG6hJ0kL5pSrY8aE1uR8oI2tY", "expires_in": 600, "interval": 5 }
What happens depends on the policy:
- allow: the action is approved at once (it's still a decision in the ledger). The first poll returns tokens.
- require_approval: an approval goes to the hinted person, by their delivery channels, with the description, amount, counterparty and binding message. The first poll returns
authorization_pending. - deny: the request answers
access_deniedwith the reason inerror_description.
4. Poll the token endpoint
Poll POST /v1/oauth/token with grant_type=urn:openid:params:grant-type:ciba and the auth_req_id, authenticating the client the same way, no more often than interval seconds:
| Answer | Meaning |
|---|---|
authorization_ | The person hasn't decided |
slow_ | You polled faster than interval; it's now 5 seconds longer |
access_ | The person declined, or the policy denied it. error_ is the reason code: unrecognized, wrong_, not_ or off_ for a person's decline |
expired_ | Nobody decided before expires_ |
invalid_ | The auth_ is unknown, belongs to another client, or was already used |
Once approved, the answer has the tokens. The auth_req_id works once.
{
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImludGVudC0xIn0…",
"token_type": "Bearer",
"expires_in": 14398,
"scope": "openid",
"id_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9…",
"authorization_details": [
{
"type": "provenance_action",
"action_type": "pay_invoice",
"description": "Pay invoice INV-1042 to Brindlecote Supplies for $2,400",
"amount": 2400,
"currency": "USD",
"counterparty": "brindlecote.example",
"receipt_id": "rcpt_3f9c2a71d84b4e06a1c5b7e2d9f04a63"
}
]
}
With several details, each also carries its own intent_token, and access_token is the first one's.
Ping instead of polling
A ping client doesn't poll while the person decides. Register it with delivery_modes including ping and an https notification_endpoint (your backchannel_client_notification_endpoint), then send a client_notification_token with each request:
| Step | What happens |
|---|---|
bc_ with client_ | The request is in ping mode |
| The person decides (or the policy allows it at once) | Provenance POSTs { "auth_ to your endpoint once, with Authorization: Bearer <client_ |
| Your endpoint answers 2xx | You poll the token endpoint once and get the tokens or access_ |
Check the bearer before you trust a ping. If your endpoint is down, the ping isn't retried, and polling still works. An expiry isn't pinged.
5. Verify the access token
The access token is a Provenance intent token, ES256, signed by a key in /.well-known/jwks.json. Check the signature, then its claims:
| Claim | Check |
|---|---|
action_ | The SHA-256 of the detail's description |
payload_ | The SHA-256 of the detail in canonical JSON (keys sorted) |
aud | Your client id |
confirmed. | approval when a person approved |
authorization_ | The detail as approved |
To check revocation and the approval server side as well, send the token to POST / with the description as action_description and the detail as action_payload.
6. Read the id token
The id token describes the person who approved this request:
| Claim | Value |
|---|---|
iss | The issuer from discovery |
aud | Your client id |
sub | A pairwise subject: stable for this person at your client, unrelated at any other |
acr | passkey, biometric or session: how they approved |
amr | ["hwk", "user"] for a passkey or biometric, ["user"] for a signed-in session |
auth_ | When they approved |
When the policy allowed the action without a person, the id token names the hinted person and carries no authentication claims. The next time you ask the same person, send sub as the login_hint or the id token as id_token_hint.
A complete client
Node (18 or later), with an ES256 key whose public half is registered on the client:
import { createPrivateKey, createSign, randomUUID } from "node:crypto";
const api = process.env.PROVENANCE_API;
const clientId = process.env.CIBA_CLIENT_ID;
const key = createPrivateKey(process.env.CIBA_PRIVATE_KEY_PEM);
const kid = process.env.CIBA_KEY_ID;
const b64u = (v) => (Buffer.isBuffer(v) ? v : Buffer.from(typeof v === "string" ? v : JSON.stringify(v))).toString("base64url");
function assertion(aud) {
const now = Math.floor(Date.now() / 1000);
const input = `${b64u({ alg: "ES256", kid, typ: "JWT" })}.${b64u({ iss: clientId, sub: clientId, aud, jti: randomUUID(), iat: now, exp: now + 120 })}`;
const sig = createSign("SHA256").update(input).sign({ key, dsaEncoding: "ieee-p1363" });
return `${input}.${b64u(sig)}`;
}
async function post(path, fields) {
const body = new URLSearchParams({
...fields,
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
client_assertion: assertion(`${api}${path}`),
});
const res = await fetch(`${api}${path}`, { method: "POST", body });
return res.json();
}
const start = await post("/v1/oauth/bc_authorize", {
scope: "openid",
login_hint: "ana@acme.example",
binding_message: "Code 7Q4-K2",
authorization_details: JSON.stringify([
{ type: "provenance_action", action_type: "pay_invoice", description: "Pay invoice INV-1042 to Brindlecote Supplies for $2,400", amount: 2400, currency: "USD", counterparty: "brindlecote.example" },
]),
});
if (start.error) throw new Error(`${start.error}: ${start.error_description}`);
let interval = start.interval;
for (;;) {
await new Promise((r) => setTimeout(r, interval * 1000));
const t = await post("/v1/oauth/token", { grant_type: "urn:openid:params:grant-type:ciba", auth_req_id: start.auth_req_id });
if (t.error === "authorization_pending") continue;
if (t.error === "slow_down") { interval += 5; continue; }
if (t.error) throw new Error(`${t.error}: ${t.error_description}`);
console.log("approved", t.authorization_details[0].receipt_id);
break;
}
Python, with httpx and cryptography:
import json, os, time, uuid, base64
import httpx
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature
api = os.environ["PROVENANCE_API"]
client_id = os.environ["CIBA_CLIENT_ID"]
kid = os.environ["CIBA_KEY_ID"]
key = serialization.load_pem_private_key(os.environ["CIBA_PRIVATE_KEY_PEM"].encode(), password=None)
def b64u(b: bytes) -> str:
return base64.urlsafe_b64encode(b).rstrip(b"=").decode()
def assertion(aud: str) -> str:
now = int(time.time())
header = b64u(json.dumps({"alg": "ES256", "kid": kid, "typ": "JWT"}).encode())
payload = b64u(json.dumps({"iss": client_id, "sub": client_id, "aud": aud, "jti": str(uuid.uuid4()), "iat": now, "exp": now + 120}).encode())
r, s = decode_dss_signature(key.sign(f"{header}.{payload}".encode(), ec.ECDSA(hashes.SHA256())))
return f"{header}.{payload}.{b64u(r.to_bytes(32, 'big') + s.to_bytes(32, 'big'))}"
def post(path: str, fields: dict) -> dict:
data = {**fields, "client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", "client_assertion": assertion(api + path)}
return httpx.post(api + path, data=data).json()
start = post("/v1/oauth/bc_authorize", {
"scope": "openid",
"login_hint": "ana@acme.example",
"binding_message": "Code 7Q4-K2",
"authorization_details": json.dumps([{"type": "provenance_action", "action_type": "pay_invoice", "description": "Pay invoice INV-1042 to Brindlecote Supplies for $2,400", "amount": 2400, "currency": "USD", "counterparty": "brindlecote.example"}]),
})
if "error" in start:
raise SystemExit(f"{start['error']}: {start['error_description']}")
interval = start["interval"]
while True:
time.sleep(interval)
t = post("/v1/oauth/token", {"grant_type": "urn:openid:params:grant-type:ciba", "auth_req_id": start["auth_req_id"]})
if t.get("error") == "authorization_pending":
continue
if t.get("error") == "slow_down":
interval += 5
continue
if "error" in t:
raise SystemExit(f"{t['error']}: {t['error_description']}")
print("approved", t["authorization_details"][0]["receipt_id"])
break
Errors you might see
The OAuth endpoints answer RFC 6749 errors, { "error", "error_description", "error_uri", "request_id" }, so existing CIBA libraries read them unchanged. invalid_client is a 401; the others are 400.
error | When |
|---|---|
invalid_ | Unknown or disabled client, a wrong secret, or an assertion that fails: signature, aud, exp more than 5 minutes out, a reused jti, or a JWKS URL that couldn't be fetched |
invalid_ | A missing scope/openid, no hint or more than one, user_, a requested_ under 60 |
invalid_ | A scope the client isn't allowed |
unknown_ | The hint doesn't name a person on the account |
invalid_ | Not 1 to 5 valid provenance_ objects |
invalid_ | Over 64 characters |
unauthorized_ | A detail type or delivery mode the client isn't allowed |
access_ | The policy denied it (error_ is the reason) |
Limits
- 60 backchannel requests a minute per client.
- Requests wait 10 minutes by default and 30 at most.
- Each action is one metered decision, as a verify is.
- Push delivery mode and user codes aren't offered, and a hint never reaches a person the account hasn't added.