Skip to content

OIDC identity

Signed Run tokens that name the agent or the person, with no stored secret.

Updated

An agent can call your internal APIs and MCP servers with a short signed token instead of a static secret. cloudraker.run is the OpenID Connect issuer of your org. The token names the agent, or the person who talks to the agent. Your API verifies the token with the public keys of the issuer and applies its own access rules. You store no secret in Run, and Run stores no token.

Use it when:

  • your API must know which person asked, and apply the access rules of that person, or
  • your API must know which agent calls it, and you do not want to rotate a shared API key.

How it works

  1. You add an oidc: block to a host in network:, or you create a connector with the auth type Run identity (OIDC).
  2. On each request to that host, the egress layer gets a token from the Run issuer. The token is valid for 300 seconds at most and for one audience.
  3. The egress layer puts the token in a header: Authorization: Bearer {token} by default.
  4. Your API verifies the signature, the issuer, the audience, the subject and the expiry. Then it applies its own rules.

The agent, the model and the agent code never see the token. The egress layer redacts it from the response and from traces, like a secret value.

Issuer and keys

Each org has its own issuer. The issuer is the org host: https://{org}.cloudraker.run, for example https://acme.cloudraker.run.

Document URL
Issuer https://{org}.cloudraker.run
Discovery https://{org}.cloudraker.run/.well-known/openid-configuration
JWKS https://{org}.cloudraker.run/.well-known/jwks.json

Both documents are public. They need no token and no Run access. The console Settings screen shows the issuer URL and the JWKS URL of your org, with a copy button. A custom domain and a preview host do not serve these documents. Always use the org host.

The discovery document has issuer, jwks_uri, id_token_signing_alg_values_supported: ["RS256"], claims_supported and scopes_supported. The tokens are RS256 JWTs. The JWT header has alg, typ and kid.

Configure a host

Add oidc: to an exact host in network:. identity is required.

network:
  # The token names the person of the turn. The audience is https://api.internal.acme.com.
  api.internal.acme.com:
    oidc:
      identity: user

  # The token names the agent, with a custom audience and header.
  vault.acme.com:
    oidc:
      identity: agent
      audience: vault://run
      header: X-Run-Token
Key Type Default Rule
network.{host}.oidc.identity agent or user none (required) agent: the token names the agent. user: the token names the person of the turn.
network.{host}.oidc.audience string, 1 to 512 characters https://{host} The aud claim. With identity: user, the only value is https://{host} (lint oidc_user_audience).
network.{host}.oidc.header header name Authorization Authorization gets Bearer {token}. Another header gets the bare token. Host, Cookie and other transport headers are refused.
network.{host}.oidc.scopes list of scope names none The scope claim, for the CloudRaker API of your org. Read Call the CloudRaker API.

The token goes to every request that the agent sends to the host: a plain fetch, an _apis operation, a _code script and an mcp.json server on that host. Model calls and the download of request files never get a token.

oidc deep-merges by key, like the rest of network:. A root agent.yml can set the block for every agent. Lint runs on the resolved config of each agent. So a leaf that sets identity: user under a parent audience fails with oidc_user_audience.

Why a user token has a fixed audience

A person can use an agent that a repo writer controls. If a user token could carry any audience, a repo writer could send the token of a person to a host that the writer controls. Then the writer could replay that token at your API. With the audience fixed to the receiving host, your API refuses a token that it did not receive itself.

An agent token can have a custom audience, because it names only the agent.

Call the CloudRaker API

Your org trusts its own issuer by default. So an agent can call the API of your org on https://{org}.cloudraker.run/v2, with no key in the repo. Put oidc: with scopes on the org host:

network:
  acme.cloudraker.run:
    oidc:
      identity: agent
      scopes: [parse, extract, jobs:read]

These rules apply:

  • The host and the audience are both the org host. The audience defaults to https://{org}.cloudraker.run. Do not set another value. Each step that makes a tree live fails with oidc_scopes_audience: a push, a merge, a redeploy, a door save and the first save of an empty project. The egress layer and the issuer also refuse the token at run time.
  • scopes holds at least one name, and each name only once. You can use the capability scopes (parse, extract, classify, split, fill, redact, generate, convert, redline, sign, transcribe, agents), jobs:read, run, read and cancel.
  • An agent cannot get admin, secrets, act_as, git or preview. The schema refuses these names.
  • Use identity: agent. The API accepts the agent identity only, and it refuses a user token.
  • Branch preview runs get no API scopes. The API refuses a token with a branch claim. Test API calls on a live deployment.

Configure a connector

An org admin can create a connector with the auth type Run identity (OIDC). Read Connectors. The connector needs no login and stores no token. Its status is connected.

The agent picks the identity in connectors:. The default is agent.

connectors:
  - name: crm
    identity: user # the token names the person of the turn
  - name: wiki # the token names the agent

The admin sets the audience of the connector. The default is https://{host} of the server URL. The admin sets the URL and the audience together, so a connector can send a user token with a custom audience.

Token claims

Claim Token Value
iss all https://{org}.cloudraker.run.
sub all agent:{repo}/{agent} or user:{workos_user_id}. Read Subjects.
aud all The audience of the rule. One string.
iat, nbf all The time of signing, in seconds.
exp all 300 seconds after iat at most, 60 seconds at least.
jti all A unique id of the token.
org all The org slug, for example acme.
agent all {repo}/{agent}, for example support/triage.
run_id all The run that sent the request, for example run_01K7Q3V9X2M4N6P8R0S2T4V6W8.
deployment all The commit SHA of the deployment that the run uses.
identity all agent or user.
branch preview run The branch of a preview run. A live run has no branch claim.
scope with scopes The scopes of the rule, separated by spaces. Absent when the rule has no scopes.
email user The email address of the person.
email_verified user Always true.
act user { "sub": "agent:{repo}/{agent}" }: the agent that acts for the person (RFC 8693).

An agent token:

{
  "iss": "https://acme.cloudraker.run",
  "sub": "agent:support/triage",
  "aud": "vault://run",
  "iat": 1793260800,
  "nbf": 1793260800,
  "exp": 1793261100,
  "jti": "3f1c9a52-6b7e-4d0a-9c1e-8a2b7c4d5e6f",
  "org": "acme",
  "agent": "support/triage",
  "run_id": "run_01K7Q3V9X2M4N6P8R0S2T4V6W8",
  "deployment": "9c1e8a2b7c4d5e6f3f1c9a526b7e4d0a9c1e8a2b",
  "identity": "agent"
}

A user token adds the person:

{
  "iss": "https://acme.cloudraker.run",
  "sub": "user:user_01J8Z6Q4N2M0K8H6F4D2B0Z8X6",
  "aud": "https://api.internal.acme.com",
  "iat": 1793260800,
  "nbf": 1793260800,
  "exp": 1793261100,
  "jti": "7a2b9c1e-4d5e-4f6a-8b3c-2d1e0f9a8b7c",
  "org": "acme",
  "agent": "support/triage",
  "run_id": "run_01K7Q3V9X2M4N6P8R0S2T4V6W8",
  "deployment": "9c1e8a2b7c4d5e6f3f1c9a526b7e4d0a9c1e8a2b",
  "identity": "user",
  "email": "jane@acme.com",
  "email_verified": true,
  "act": { "sub": "agent:support/triage" }
}

Subjects

Identity sub Notes
Agent agent:{repo}/{agent} The repo name and the agent path. Two agents never share a subject.
User user:{workos_user_id} The WorkOS user id of the person, user_.... It does not change when the email address of the person changes.

The prefix keeps the two sets apart. An agent subject never matches a user subject.

Who counts as the person

identity: user names the person of the turn. Only a verified member of your org counts. For other turns, no person exists, and the egress layer sends no user token. Read When the token is not available for the result.

Turn Person
A member who uses the console: chat, test runs, team apps and app actions Yes
A Slack or Teams sender who is an active org member with a verified email Yes
A child run that a lead agent starts The person of the lead turn
A tool call that a person approves The person of the turn that asked, not the approver
A mention run in a console conversation, with no sender The conversation owner. The owner did not send this turn.
A Slack or Teams sender who is not an org member, or has no verified email No
A schedule, an inbound webhook or an event No
A phone caller No
An email sender, also with a DMARC pass No
A web chat visitor No
An API call with a crk_ key, also with x-run-as No

A protection: public agent never has a person. Lint refuses identity: user on its hosts and connectors with user_identity_source.

When the token is not available

The request does not leave when the egress layer cannot get a token. The run goes on. The result depends on the tool:

  • A fetch, an _apis operation or a _code request: the tool call fails with identity_unavailable. The agent can try another way, or tell the person.
  • An MCP server or a connector: the engine lists the tools of the server before the first step, and that request also needs the token. The tools of that server are not available in the turn. The model does not see them, and no tool call returns identity_unavailable.

This happens when:

  • the rule has identity: user and the turn has no person, or
  • the Run issuer does not answer.

A user rule never falls back to the agent identity. It never sends the request without a token.

Preview runs

A run on a branch preview can get both identities. Its tokens have the branch claim. Refuse a token with a branch claim when your API must not serve previews. The CloudRaker API always refuses it.

Verify a token

Always check these points:

  1. The signature, with a key from the JWKS of your org issuer. Accept RS256 only.
  2. iss: the exact issuer of your org. The key set is shared, so this check is the only org check.
  3. aud: the exact audience of your API.
  4. sub: a subject that you expect. For agent tokens, keep a list of the agent subjects that can call you. For user tokens, require the user: prefix and map the subject to your own user.
  5. act.sub: for a user token, require an agent subject that you allow. Without this check, any agent of your org can act for a member.
  6. exp and nbf, with a small clock tolerance. Do not require a fixed lifetime.
  7. branch: refuse it if you do not want preview runs.

Do not use jti as a one-time value. The egress layer reuses a token for many requests while more than 60 seconds of its life remain.

This example uses the jose library:

import { createRemoteJWKSet, jwtVerify } from 'jose'

const ISSUER = 'https://acme.cloudraker.run'
const AUDIENCE = 'https://api.internal.acme.com'
const ALLOWED_AGENTS = new Set(['agent:support/triage'])

// jose caches the keys and fetches them again for an unknown kid.
const jwks = createRemoteJWKSet(new URL(`${ISSUER}/.well-known/jwks.json`))

export async function verifyRunToken(request: Request) {
  const header = request.headers.get('authorization') ?? ''
  if (!header.startsWith('Bearer ')) throw new Error('missing token')

  const { payload } = await jwtVerify(header.slice('Bearer '.length), jwks, {
    issuer: ISSUER, // pin the org: one key set signs for every org
    audience: AUDIENCE, // pin your API
    algorithms: ['RS256'],
    clockTolerance: 30, // seconds; jwtVerify checks exp and nbf
  })

  if (payload.branch !== undefined) throw new Error('preview tokens are refused')

  const sub = String(payload.sub)
  if (payload.identity === 'user' && sub.startsWith('user:')) {
    const actor = (payload.act as { sub?: string } | undefined)?.sub
    if (!actor || !ALLOWED_AGENTS.has(actor)) throw new Error('agent not allowed')
    return { kind: 'user' as const, userId: sub.slice('user:'.length), email: payload.email }
  }
  if (payload.identity === 'agent' && ALLOWED_AGENTS.has(sub)) {
    return { kind: 'agent' as const, agent: payload.agent }
  }
  throw new Error('subject not allowed')
}

Keys, rotation and caching

  • The JWKS answer has Cache-Control: public, max-age=3600 when a key signs. Without an active key, the answer has no-store. Cache the key set for one hour at most.
  • When a token has a kid that is not in your cache, fetch the JWKS again. createRemoteJWKSet of jose does this.
  • CloudRaker rotates the keys by hand. A new key is in the JWKS one hour before it signs. An old key stays in the JWKS for one hour after it stops signing. A verifier that follows the cache rules sees no failure.

Audit

The egress audit row of a request with a token has secret_names: ["oidc:agent"] or ["oidc:user"]. No row and no trace holds the token. The console agent page shows “Agent identity” or “User identity” next to each host with an oidc block.

Lint rules

Code Level Rule
oidc_wildcard error oidc on a *. host. Use exact hosts.
oidc_user_audience error identity: user with an audience other than https://{host}.
oidc_header_conflict error oidc and headers set the same header on one host.
oidc_scopes_audience error scopes on a rule whose host or audience is not the org host. Each step that makes a tree live runs this rule. A draft save in the Console does not, and rakerun lint does not.
user_identity_source error identity: user on a host or a connector of a protection: public agent.
api_security_header warning An oidc header counts as supplied. An _apis file that needs Authorization gets no warning when the host has oidc.

Limits

Limit Rule
Hosts Exact hosts only. The egress layer also refuses a wildcard at run time.
Redirects Each hop is checked again. A hop to another host gets a token only when that host has its own rule, with its own audience.
Transport The token goes in one request header only. Never in a URL, a query string or a body.
Lifetime 60 to 300 seconds (exp - iat). The egress layer reuses a token while more than 60 seconds remain. You cannot set it.
Audience One audience per rule. A user token has the audience https://{host} on a network: host.

These features are not available yet:

  • keys for each org, and automatic key rotation,
  • a token in a request body, for example for the AWS or Google Cloud token exchange,
  • a token that _code can read,
  • a person from an email sender, Cloudflare Access or the x-run-as header,
  • a custom audience for user tokens from an admin allow list.

Type to search…

↑↓ navigate↵ selectEsc close