Repository navigation
Add trust policies, token exchange and agent tokens - #30
Merged
Merged
Conversation
The client side of RFC-0005 releases 5 (deploys from CI) and 7 (agent tokens): - valar trust add|list|remove (aliases create and delete) manage a project's trust policies. --github-repo with --branch, --environment or --pull-requests builds a GitHub Actions policy: it reads the repository's and owner's IDs and the OIDC subject format from GitHub, writes the subject as GitHub issues it (immutable IDs, custom claim keys), and pins repository_id, repository_owner_id and, for branches and environments, event_name and workflow_ref. --subject and --claim set a policy by hand. - valar auth exchange trades a CI identity token for a one-hour token bound to one service. It reads the identity token from --id-token, --id-token-file, the GitHub Actions request variables (audience: the endpoint's origin, or --audience) or stdin, sends no Authorization header, masks the token in GitHub Actions and with --export writes it to GITHUB_ENV. A refusal shows the claims a policy matches. - valar token create --agent mints a read-only agent token bound to a project (7 days by default, 30 at most) and prints how to configure MCP clients with the /mcp URL and the token in an environment variable. - valar service url reads the inspect route, which service-bound tokens may read, and falls back to the listing on older platforms.
- A --github-repo policy pins the branch's ref or the environment as a
claim when the repository's subject template leaves out its context,
so a template such as ["repo"] no longer admits every branch and
environment.
- trust add refuses, unless --force, policies for pull_request_target,
workflow_run and issue_comment jobs and hand-written pull_request
subjects for a service rather than a preview prefix, and warns when a
hand-written GitHub policy pins no repository ID.
- auth exchange prints, masks or exports only a value matching
^valar_ut_[0-9a-f]{64}$, so a malformed answer cannot write further
variables into GITHUB_ENV.
- auth exchange drops --id-token, which put the identity token on the
command line; --id-token-file (- for stdin) and the GitHub Actions
request remain.
- The docs no longer claim that forks never get identity tokens: private
repositories can send them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The client side of RFC-0005 release 5 (deploys from CI) and release 7 (agent tokens), plus
service urlon the inspect route.Commands
valar trust add|list|remove(aliasescreate,delete) for/v2/projects/{p}/trust-policies.add --service <name or prefix*>with either--github-repo owner/repoand one of--branch,--environmentor--pull-requests, or--subjectand--claim k=vby hand.--issuerdefaults to GitHub Actions' issuer.--github-reporeads the repository's and owner's IDs and/actions/oidc/customization/subfrom GitHub (GH_TOKEN/GITHUB_TOKENfor private repositories). It writes the subject as GitHub issues it:sub_claim_prefix(immutable IDs where the repository uses them), and custominclude_claim_keyswhere it knows every key's value. It pinsrepository_idandrepository_owner_id, and for branch and environment policies alsoevent_name(--event, defaultpush) andworkflow_ref(--workflow, required).["repo"]), the policy pins the branch'srefor theenvironmentas a claim, so it still admits only that branch or environment.--pull-requests,--pull-requestswithout one, and subject keys it can't know.--force:--eventor--claim event_name=ofpull_request_target,workflow_runorissue_comment, and a hand-written subject with apull_requestsegment for a service rather than a preview prefix. A hand-written GitHub policy withoutrepository_id(in a claim or an immutable or custom subject) gets a warning.valar auth exchange [--service] [--project] [--id-token-file path|-] [--audience] [--export]callstoken-exchangewith noAuthorizationheader.--id-token-file, fromACTIONS_ID_TOKEN_REQUEST_URL/_TOKEN(audience: the endpoint's origin unless--audience), or from stdin. There is no flag that takes the token itself, so it stays out ofpsand shell history.^valar_ut_[0-9a-f]{64}$; anything else fails before it is printed, masked or exported, so a malformed value cannot add lines to$GITHUB_ENV.::add-mask::, and with--exportit appendsVALAR_TOKENto$GITHUB_ENVinstead of printing.sub,ref, IDs,event_name,workflow_ref), read unverified from the JWT.valar token create --agentsendskind: agentwithscopes: [read]and needs--project.--ttlis checked against 30 days and defaults to the server's 7./mcpURL and how to configure clients without writing the token into a config file: anmcp add --transport http ... --header 'Authorization: Bearer ${VALAR_AGENT_TOKEN}'command and a genericmcpServersentry. It also warns against agents that can read~/.valar(RFC-0011).--jsonaddsmcpUrl.valar service urlreadsGET .../inspect(urls), so service-bound tokens work, and falls back to the listing when the server answers an unknown-route 404.The API client now omits
Authorizationwhen it has no token. The README and the agent skill document the new commands.Server dependencies
[API.OIDC]on the installation. Until then the commands report "the server has no trust policies or token exchange"./v2/tokenswithkind: agent(#487, merged) andapi.mcp.enabled, which arrives with #523. Until then the server refuses the token with its own reason.service urluses inspect (#467, merged).Test steps
go vet ./... && go test -race ./...[API.OIDC]test issuer:valar trust add --service web --github-repo <owner/repo> --branch main --workflow deploy.yml, thenvalar trust list.valar auth exchange --service web --id-token-file token.jwt.valar trust add --service web --subject repo:<owner/repo>:pull_requestis refused; with--service 'webpr*'it is accepted.VALAR_TOKEN, runvalar build push --wait, thenvalar service url.valar trust remove <id>. The token then fails with "revoked".api.mcp.enabled:valar token create agent --agent --project <p>. Add the printed configuration to an MCP client and list tools.valar service urlwith a token bound to one service prints its URLs.