Skip to content

Deploy with the job's identity token when no token is given - #14

Merged
lnsp merged 3 commits into
masterfrom
oidc-deploys
Nov 22, 2026
Merged

lnsp merged 3 commits into
masterfrom
oidc-deploys

Conversation

@lnsp

@lnsp lnsp commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

RFC-0005 release 5 lets a job deploy with its GitHub identity token instead of a stored token. This PR adds that mode.

CLI version: the default cli-version is now 4.11.0, the first CLI release with valar/cli#30 (valar auth exchange), and scripts/checksums.txt has its 5 assets.

Behaviour

  • token is optional now. When it is given, the action passes it to the CLI unchanged, as before.
  • Without token, the job needs permissions: id-token: write, which sets ACTIONS_ID_TOKEN_REQUEST_URL. Without that permission, the step fails and names both options.
  • Without token, the step refuses to exchange in pull_request_target and workflow_run runs (GITHUB_EVENT_NAME), which run with the repository's credentials on input from pull requests.
  • With the permission, the step runs valar auth exchange [--service s] [--audience a] after it has worked out the service (input, preview, or .valar.yml through the CLI).
    • The CLI requests the identity token for the endpoint's origin (or the new audience input) and exchanges it at token-exchange.
    • The step masks the returned token and exports it as VALAR_TOKEN for the rest of the step.
    • The step fails unless the CLI succeeds and returns exactly one line matching ^valar_[a-z]{2}_[0-9a-f]{64}$, so nothing else is masked or exported. An older CLI without auth exchange returns no such value.
  • Previews take the number from GITHUB_REF (refs/pull/<n>/merge|head), the same value as the identity token's ref claim that preview policies match. It falls back to the event's number. Closing and reopening a preview exchange first, then disable or enable.
  • The README leads with the identity-token setup:
    • permissions: id-token: write and valar trust add ... --github-repo ... --environment|--branch|--pull-requests;
    • deployment branch rules for environment policies;
    • valar trust list|remove;
    • the stored-token fallback, and why the build-only PR check keeps a stored token;
    • not to rely on the action's fork check, which runs in the pull request's own copy of the workflow. Private repositories can send secrets and identity tokens to fork pull requests, and the trust policy's pinned subject, event and ref are what bound a job.
  • The composite action gets the identity token through the CLI from the runner's request variables, which is what @actions/core's getIDToken(audience) uses; there is no Node step.

Before merging

  • With a cli-version older than 4.11.0, the identity-token mode fails with the "needs a Valar CLI with 'valar auth exchange'" error; the stored-token mode is unchanged.
  • The server side is valar/platform#519, with [API.OIDC] set on the installation.
  • scripts/deploy_test.sh is new and not yet run in CI. CI's existing shellcheck step covers it (scripts/*.sh). Running it in ci.yml needs a workflow change, left to a separate PR.

Test steps

  • bash scripts/deploy_test.sh, which checks:
    • a stored token;
    • an exchanged token used by build push and service url;
    • the audience input;
    • no token and no permission;
    • a refused exchange, an older CLI, a two-line answer and a short token;
    • pull_request_target and workflow_run without a token (refused), and workflow_run with a token (unchanged);
    • a preview: synchronize, closed (disable) and reopened (number from a head ref);
    • forks.
  • shellcheck scripts/*.sh
  • In a test repository against a platform with #519 and CLI 4.11.0 (the default):
    • add valar trust add --service <s> --github-repo <repo> --branch main --workflow <file>, run the workflow with id-token: write and no token, and check the deploy and the URL;
    • remove the policy and rerun: the step fails and the log shows the identity token's claims.

lnsp added 3 commits November 21, 2026 23:28
The token input becomes optional (RFC-0005 release 5). Without it, the
action runs valar auth exchange, which requests the job's GitHub identity
token for the endpoint's origin (or the new audience input) and exchanges
it under the project's trust policy for a one-hour token bound to the
service. The token is masked and exported for the rest of the step. A
given token is passed to the CLI unchanged, as before.

Previews take the pull request number from GITHUB_REF, which is also the
identity token's ref claim that preview policies match.

scripts/deploy_test.sh runs deploy.sh against a stub CLI and checks the
calls for a stored token, an exchanged one, refusals, an older CLI and
previews.

The README recommends a trust policy over a stored token and documents
the id-token permission, deployment branch rules for environment
policies, and the fallback to a stored token.
- Without a token input, the action refuses to exchange identity tokens
  in pull_request_target and workflow_run runs.
- The exchanged value must be one line matching
  ^valar_[a-z]{2}_[0-9a-f]{64}$ before it is masked and exported.
- The README no longer relies on the fork check, which runs in the pull
  request's own copy of the workflow: private repositories can send
  secrets and identity tokens to fork pull requests, and what bounds an
  identity token is the trust policy's pinned subject, event and ref.
Adds the checksums of the CLI 4.11.0 release assets and makes 4.11.0 the default cli-version. 4.11.0 is the first release with valar auth exchange, which the identity-token mode needs.
@lnsp
lnsp marked this pull request as ready for review November 22, 2026 21:59
@lnsp
lnsp merged commit c7a3140 into master Nov 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant