CI Workload Tokens
How a CI job gets a short-lived token for your product without a stored key, and how your product accepts it.
A CI job on branchd can call your product without a stored API key. The job asks pipelines for a job identity token, exchanges it at Xeonr Auth, and receives a token of at most five minutes for one product. The token says which run asked: the repository, the team, the ref and commit, whether the ref is protected, who started the run. It grants nothing on its own beyond its scopes. Your product decides what that run may do, from those facts and its own settings.
What Auth checks
For each exchange Auth checks only:
- The job token is genuine and unused: signed by pipelines, for the forge's tenant, from a run the forge itself created and started, at most ten minutes old, and never exchanged before.
- The scopes: every scope the job asks for must be one the forge's binding into your application holds. You switch your product on for CI by approving that binding in Auth, and you choose which of your scopes it holds. A scope you withdraw stops being issued at once. Administrative scopes are never issued.
- The team: the repository's team must be entitled to your application.
- Narrowing: if the job asks for authorization details, each must be one of your application's registered, enforced resource types, with actions the token carries. Auth stores them; your product reads them by reference.
Auth does not know your product's resources, which steps exist, or which repositories may do what. It does not look at the step that asked: a pipeline's run: line can ask for a token just like a published step can.
Requesting a token
From a job, the forge's credential helper does this for you. The exchange itself is RFC 8693:
POST /api/v1/oauth/token HTTP/1.1
Host: auth.xeonr.io
Content-Type: application/x-www-form-urlencoded
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange
&subject_token=<job identity token, audience <forge tenant>/<application slug>>
&subject_token_type=urn%3Axeonr%3Aparams%3Aoauth%3Atoken-type%3Ajob_identity
&audience=urn%3Axeonr%3Aauth%3Aworkload-audience%3A<application slug>
&scope=<optional: a subset of what the binding holds>
&authorization_details=<optional: RFC 9396, narrows the token>No client authenticates: the job identity token is the credential. The response is an access token with token_type=Bearer and no refresh token.
The token your product receives
sub:urn:xeonr:auth:workload:forge:<repository path>#<package name>aud:urn:xeonr:auth:workload-audience:<application slug>, never your ordinary audiencescope, andamr: ["workload"]urn:xeonr:auth:workload: the run's facts:run,node,attempt,run_number,repository {id, path},team,ref,sha,source,protected,merge_queue,reviewed,via,actor,run_creator,run_trigger, andpackagefor your audit log.
The team lookup for the token answers the repository's team with role member and no product role.
Accepting it in your product
With go-platform's authn:
- Add your workload audience to
authn.Config.Audiences. Until you do, workload tokens are refused. - Opt in the methods CI may call with
authn.AllowWorkloads(...). Every other method refuses a workload, whatever its scopes. - Read
p.Workload()and decide with your own settings: which repositories (by id, not path, so a reused path inherits nothing) or groups may do what, and whether a write needs a protected run. Do not decide on the package name. - To honour narrowing, declare your resource types in
authn.Config.ResourceTypesand checkclaims.Resolver.Resources(ctx, p).Allows(scope, type, identifier). - Record the token's
sub,run,repositoryandteamin your audit log.
Rich Authorization Requests (RAR)
Request fine-grained resource-level permissions using authorization_details.
xeonr.auth.api.v1.ApiKeysService
ApiKeysService is how a product issues and verifies API keys without implementing them. Every method is for the product's own service account, about the product's own application: a key is created, listed, updated, revoked and verified only by the application it belongs to. Keys are long-lived bearer secrets of the form `xk_<40 chars><6-char checksum>`, stored hashed and returned exactly once. A product presents a key it receives to VerifyApiKey (go-platform's authn does this, with a short cache) and acts on the answer. Auth itself never accepts an API key as a caller credential; a key is only ever a token in VerifyApiKey's request body.