---
title: "Job identity (OIDC) and signing: ModernCI docs"
description: "Short-lived job tokens for keyless signing and cloud federation."
url: https://modernci.dev/docs/oidc/
---

# Job identity (OIDC) and signing

ModernCI is an OpenID Connect identity provider for jobs. A running job can ask for a
short-lived token that says exactly which repository, ref, commit, check and run it is. Use the
token for keyless signing with Sigstore, and for cloud federation (AWS, GCP, Azure) without stored
secrets. This is the same pattern as GitHub Actions OIDC.

- Issuer: `https://oidc.modernci.dev` (one global issuer).
- Discovery: `https://oidc.modernci.dev/.well-known/openid-configuration`.
- Keys (JWKS): `https://oidc.modernci.dev/.well-known/jwks`.
- Signing algorithm: `ES256`.

## Getting a token inside a job

The runner puts two variables in the job's environment:

| Variable | Meaning |
|---|---|
| `MCI_ID_TOKEN_REQUEST_URL` | the token endpoint of the region running the job |
| `MCI_ID_TOKEN_REQUEST_TOKEN` | a credential for this job only; it is a secret and is redacted from logs |

```sh
curl -sH "Authorization: Bearer $MCI_ID_TOKEN_REQUEST_TOKEN" \
     "$MCI_ID_TOKEN_REQUEST_URL?audience=sigstore" | jq -r .value
```

The answer is `{"value": "<jwt>", "expires_at": <unix seconds>}`. `audience` is required: use
`sigstore` for Sigstore, `sts.amazonaws.com` for AWS, and so on.

## Token claims

| Claim | Example | Meaning |
|---|---|---|
| `iss` | `https://oidc.modernci.dev` | issuer |
| `sub` | `repo:git.example.com/acme/widgets:ref:refs/heads/main` | `repo:<host>/<owner>/<repo>:ref:<ref>` |
| `aud` | `sigstore` | the audience the job asked for |
| `exp`, `iat`, `nbf` | `1794300300` | lifetime: at most 10 minutes (5 by default) |
| `jti` | `9f2c…` | unique token id |
| `tenant`, `project` | `t_acme`, `p_widgets` | ModernCI tenant and project |
| `server_url` | `https://git.example.com` | the git host |
| `repository` | `acme/widgets` | owner and repository |
| `repository_owner` | `acme` | owner |
| `repository_id`, `repository_owner_id` | `1042`, `17` | the git host's stable ids (survive renames) |
| `repository_visibility` | `public` | `public`, `private` or `internal` |
| `ref` | `refs/heads/main` | the ref being built |
| `sha` | `4b825dc6…` | the commit being built |
| `check` | `release` | the check |
| `run_id`, `run_attempt`, `job_id` | `r_01JC2Z`, `1`, `j_01JC30` | the run, its attempt, the job |
| `runner_environment` | `modernci-hosted` | `modernci-hosted` or `self-hosted` |
| `config_ref` | `acme/widgets/.ci/checks.yaml@refs/heads/main` | the check configuration that defined the job |
| `config_sha` | `4b825dc6…` | the commit the configuration was read from |
| `trigger` | `push` | `pull_request`, `merge_queue`, `push`, `manual` or `schedule` |
| `landed` | `true` | the commit is on a branch only ModernCI lands to |
| `run_url` | `https://app.modernci.dev/acme/widgets/runs/r_01JC2Z` | the run's page |

Example token body:

```json
{
  "iss": "https://oidc.modernci.dev",
  "sub": "repo:git.example.com/acme/widgets:ref:refs/heads/main",
  "aud": "sigstore",
  "exp": 1794300300, "iat": 1794300000, "nbf": 1794300000,
  "jti": "9f2c4be1d0a34f7e8b1c2d3e4f506172",
  "tenant": "t_acme", "project": "p_widgets",
  "server_url": "https://git.example.com",
  "repository": "acme/widgets", "repository_owner": "acme",
  "repository_id": "1042", "repository_owner_id": "17",
  "repository_visibility": "public",
  "ref": "refs/heads/main", "sha": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
  "check": "release", "run_id": "r_01JC2Z", "run_attempt": "1", "job_id": "j_01JC30",
  "runner_environment": "modernci-hosted",
  "config_ref": "acme/widgets/.ci/checks.yaml@refs/heads/main",
  "config_sha": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
  "trigger": "push", "landed": true,
  "run_url": "https://app.modernci.dev/acme/widgets/runs/r_01JC2Z"
}
```

## Fulcio certificate extensions

A Sigstore certificate issued for a ModernCI token carries these extensions (OIDs under
`1.3.6.1.4.1.57264.1`). Templates use Fulcio's syntax: a bare name is that claim's value. The
certificate's subject alternative name (a URI) is `{{ .server_url }}/{{ .config_ref }}`, e.g.
`https://git.example.com/acme/widgets/.ci/checks.yaml@refs/heads/main`.

| OID | Extension | Template | Example |
|---|---|---|---|
| `1.3.6.1.4.1.57264.1.8` | Issuer (V2) | `iss` | `https://oidc.modernci.dev` |
| `1.3.6.1.4.1.57264.1.9` | Build Signer URI | `{{ .server_url }}/{{ .config_ref }}` | `https://git.example.com/acme/widgets/.ci/checks.yaml@refs/heads/main` |
| `1.3.6.1.4.1.57264.1.10` | Build Signer Digest | `config_sha` | `4b825dc642cb6eb9a060e54bf8d69288fbee4904` |
| `1.3.6.1.4.1.57264.1.11` | Runner Environment | `runner_environment` | `modernci-hosted` |
| `1.3.6.1.4.1.57264.1.12` | Source Repository URI | `{{ .server_url }}/{{ .repository }}` | `https://git.example.com/acme/widgets` |
| `1.3.6.1.4.1.57264.1.13` | Source Repository Digest | `sha` | `4b825dc642cb6eb9a060e54bf8d69288fbee4904` |
| `1.3.6.1.4.1.57264.1.14` | Source Repository Ref | `ref` | `refs/heads/main` |
| `1.3.6.1.4.1.57264.1.15` | Source Repository Identifier | `repository_id` | `1042` |
| `1.3.6.1.4.1.57264.1.16` | Source Repository Owner URI | `{{ .server_url }}/{{ .repository_owner }}` | `https://git.example.com/acme` |
| `1.3.6.1.4.1.57264.1.17` | Source Repository Owner Identifier | `repository_owner_id` | `17` |
| `1.3.6.1.4.1.57264.1.18` | Build Config URI | `{{ .server_url }}/{{ .config_ref }}` | `https://git.example.com/acme/widgets/.ci/checks.yaml@refs/heads/main` |
| `1.3.6.1.4.1.57264.1.19` | Build Config Digest | `config_sha` | `4b825dc642cb6eb9a060e54bf8d69288fbee4904` |
| `1.3.6.1.4.1.57264.1.20` | Build Trigger | `trigger` | `push` |
| `1.3.6.1.4.1.57264.1.21` | Run Invocation URI | `run_url` | `https://app.modernci.dev/acme/widgets/runs/r_01JC2Z` |
| `1.3.6.1.4.1.57264.1.22` | Source Repository Visibility At Signing | `repository_visibility` | `public` |

ModernCI checks have no reusable-configuration indirection, so the build signer and the build
config are the same file.

## Security model

- **Who can get a token.** Only a running job. At launch ModernCI creates a random credential for
  that job, keeps only its hash, and gives the secret to the runner over the job's secret channel
  (never on a command line; redacted from logs). The token endpoint answers only while the job is
  running; once it finishes the credential is refused.
- **Isolation between tenants.** A credential resolves to exactly one job, and the token describes
  only that job: tenant, project, repository and commit come from ModernCI's records, never from the
  request. `sub` includes the git host, so the same owner/repository on two hosts never collide.
- **No signing keys in jobs.** Token-signing keys live behind the signing seam (a key file now;
  cloud KMS or HSM in production) in a separate process. Keyless signing in a job uses an
  ephemeral key and the job's token.
- **Short lifetime.** Tokens live at most 10 minutes (5 by default) and are audience-scoped.

## Key rotation

Each key has a start time. A new key is published in the JWKS 30 minutes before it starts signing,
so verifiers that cache the JWKS already know it. A replaced key stays published for at least the
longest token lifetime after it stops signing, so every token it signed still verifies. Cache the
JWKS for no longer than 5 minutes (the endpoint sends `Cache-Control: max-age=300`).

## Verifying ModernCI-signed artifacts

```sh
mci attestation verify widget.tar.gz \
  --bundle widget.tar.gz.sigstore.json --policy policy.json \
    [--trusted-root trusted_root.json]
```

It checks the signature, the certificate identity (issuer and subject pattern), the transparency
log inclusion proof and signed entry timestamp, and the SLSA provenance policy. Without
`--trusted-root` it uses the public Sigstore instance. A keyless policy:

```json
{
  "signer": {"keyless": {"issuer": "https://oidc.modernci.dev",
                         "subject_regex": "https://git\\.example\\.com/acme/widgets/\\.ci/.*@refs/heads/main"}},
  "transparency_log": "required",
  "certificate": {"source-repository-ref": "refs/heads/main", "runner-environment": "modernci-hosted"},
  "provenance": {"builder_id": "https://modernci.dev/builder/v1",
                 "source_repository": "https://git.example.com/acme/widgets",
                 "source_refs": ["refs/heads/main"], "landed": true}
}
```

ModernCI's own releases are signed with the platform key; verify them with a key policy
(`transparency_log` may be `optional` for offline, air-gapped verification):

```json
{"signer": {"key": {"public_keys": ["ed25519:<64 hex>"]}},
 "provenance": {"builder_id": "https://modernci.dev/builder/v1", "source_refs": ["refs/heads/main"], "landed": true}}
```

Bundles are standard Sigstore bundles, so `cosign verify-blob --bundle … --certificate-oidc-issuer
https://oidc.modernci.dev --certificate-identity-regexp …` also works once the issuer is trusted by
the Fulcio that issued the certificate.
