Authentication
Machine API keys, human OIDC sign-in, and how roles are resolved per namespace.
Every call is authenticated by one connect interceptor that resolves the caller to a principal — a set of namespaces, a role in each, and whether it holds admin. Handlers enforce against that; there is no privileged side channel, and the console is a plain client of the same API.
Machine callers — API keys
An API key belongs to exactly one namespace and carries one role there. Keys are Xeonr Auth API keys: a new one is a bearer token prefixed xk_, and a key issued before keys moved to Xeonr Auth (prefixed cpk_) keeps working unchanged.
POST /containers.api.v1.JobService/RunJob HTTP/1.1
Host: containers.xeonr.io
Authorization: Bearer xk_...
Content-Type: application/jsonThe namespace is bound to the key server-side, so a key cannot act in another namespace: a request for someone else's job or workspace fails with not_found or permission_denied, never an empty result. Every method accepts a key except CreateNamespace, which needs a team role, and GetContainersMe, which describes a person.
const { key, plaintext } = await cp.raw.namespace.issueApiKey({
namespace: "my-app",
name: "ci",
role: Role.OPERATOR,
// Optional: confine the key to these workspaces, at the same role.
workspaceIds: ["ws-site"],
// Optional: stops working after 90 days.
expiresAtUnix: BigInt(Math.floor(Date.now() / 1000) + 90 * 86400),
});NamespaceService is reached through cp.raw; the SDK models the surface a namespace-scoped caller uses. Issuing, listing and revoking keys needs the admin role in the namespace.
plaintext is returned once, on issue, and is never readable again — store it immediately. ListApiKeys shows each live key's key_id (its Xeonr Auth URN, urn:xeonr:auth:api-key:…), name, role, workspaces, display prefix, created and last-used; the namespace's workloads' agent keys are listed too. RevokeApiKey revokes one by that id, and the key is refused within 30 seconds. A key id from before the move to Xeonr Auth is not accepted; take the id from a fresh ListApiKeys. Deleting a namespace revokes every key it owns.
A key with workspace_ids reaches only those workspaces in its namespace, and none of the namespace-level workspace operations (listing or creating workspaces). Without them it reaches the whole namespace.
A key can carry a description and an expires_at_unix (unix seconds; 0 or unset is never). It is refused from that moment, and ListApiKeys shows when. Pass include_revoked to list revoked keys too, for the audit trail; each says when it was revoked in revoked_at_unix.
Deleting a workspace or snapshot removes it from every key bound to it. A key confined to that workspace alone is revoked rather than left without a restriction.
Human callers — Xeonr Auth OIDC
The console signs in through Xeonr Auth with authorization code + PKCE. The api hosts the flow itself, so the browser never handles a token in JavaScript:
| Route | What it does |
|---|---|
GET /auth/login | Starts the OIDC flow |
GET /auth/callback | Completes it and sets the session's httpOnly cookies: cp_session (the id_token) and the access token |
GET /auth/logout | Clears the session |
POST /oidc/backchannel-logout | Auth's back-channel logout: signing out of Xeonr Auth elsewhere ends this console's session too |
Who is signed in comes from the console's shared xeonr.console.v1.ConsoleProductService/GetMe. Container Platform's own view of the caller is NamespaceService/GetContainersMe: whether they are a platform admin, their teams with the namespace role each grants, and every namespace they can see with their role in it.
The console's Connect calls send its access token: the session layer turns the access-token cookie into an Authorization: Bearer header. The plain-HTTP routes a browser reaches without that header (the exec terminal, file transfer, previews) fall back to the cp_session cookie, which holds the id_token. A human token works against the API directly if you have one.
Calling the API with your own token
Two things are easy to get wrong here, and both fail in ways that don't name the cause.
Use a token issued to the console's client. Either of its tokens works: the id_token, whose audience is the console's client id, or the access token, whose audience is the Container Platform application (https://containers.xeonr.io) with the console as its client. A person's token issued to any other client is rejected as unauthenticated with "token audience does not match this service", however correctly it is scoped. (Service accounts, the MCP gateway and the xeonr-host installer are admitted on the application audience by their own rules.)
Request the scopes that carry your identity. Authorization is read from the groups claim and the structured teams claim, and both are scope-gated at the authorization server. Ask for the wrong set and you get a token that verifies fine and conveys no access at all:
| Scope | Why you need it |
|---|---|
openid | Required to get an id_token; not needed if you call with the access token |
groups | Populates the groups claim — how namespace group bindings and the platform-admin admin check resolve |
auth:teams:read | Populates the teams claim — how team-owned namespace access resolves |
So an administrative caller wants openid groups auth:teams:read, plus container-platform:admin if you are relying on the admin scope rather than the platform-admin group. Omitting groups and auth:teams:read is the common mistake: the call returns permission_denied naming a namespace, which reads as "your account lacks access" when the truth is "your token doesn't say that it has any". The denial now says which scopes are missing when it can tell.
Roles
There is no platform-side membership table for humans. A namespace declares OIDC group → role bindings; the interceptor reads the caller's groups claim and maps it through every namespace's bindings.
| Role | Can |
|---|---|
ROLE_VIEWER | Read within its namespaces: get/list jobs, sandboxes, environments, workspaces, egress events |
ROLE_OPERATOR | Everything a viewer can, plus mutate: run jobs, create sandboxes and workspaces, register/build environments, grant egress, read an app key |
ROLE_ADMIN | Cross-namespace. Reachable via the admin OIDC scope or the platform-admin group. An ADMIN-role API key is admin of its own namespace only |
Admin is unconditional rather than enumerated: an admin is not a member of every namespace, it simply passes every namespace check. NamespaceService — creating namespaces, editing group bindings and quotas, registering internal egress targets, issuing and revoking keys — is admin-only in full.
await cp.raw.namespace.updateNamespace({
namespace: "my-app",
groups: [
{ oidcGroup: "my-team", role: Role.OPERATOR },
{ oidcGroup: "support", role: Role.VIEWER },
],
});Group bindings are a full replace, as are internal_targets and image_pull_secrets. Send the complete list.
Scoped keys inside a sandbox
A sandbox's agent holds its own key rather than a namespace-wide one. Where a workspace is attached, that key carries a workspace scope: WorkspaceService will only serve operations on that one workspace id, so a compromised sidecar can't read its neighbours in the same namespace. This is issued and managed by the platform — nothing to configure.
Errors
| Code | Meaning |
|---|---|
unauthenticated | Missing, malformed, expired or revoked credential. If the message mentions the audience, you sent an access token where the id_token is expected — see Calling the API with your own token |
permission_denied | Valid credential, wrong namespace or insufficient role. If the message adds "token carries no groups or teams claims", the credential is fine and the scopes were wrong — request groups and auth:teams:read |
unimplemented | The call is real but its backing capability isn't configured in this deployment (e.g. no preview domain, no build backend) |