Repository navigation
feat(backend-vercel): send a GitHub Actions job's OIDC token - #775
Conversation
On Vercel's board, a GitHub Actions job with id-token: write now goes as its own OIDC token, made out to https://api.vercel.com/v1/messageboard and sent as a Bearer token: after an app's login, the deployment's OIDC token, and BOARD_TOKEN, and before vercel login. A GitHub token names no team, so with no --scope or VERCEL_ORG_ID a request fails before it's sent with missing_team. Grants naming --github or --oidc, and explains for them, go to Vercel's API as they are: the client no longer rewrites unsupported_principal into a hint about apps and exchange policies. vercel() reads the API's github and oidc principals and shows them as workflows, by repository and by subject.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The CI guide's GitHub Actions and GitLab steps for the team's board now run vercel board, with the team's ID in --scope or VERCEL_ORG_ID, and note that this needs a Vercel CLI release that runs vercel board without a login. With none on the runner, it hands board no login, so the job's own token goes. A board of your own at BOARD_URL keeps vb.
…es with to its team and Vercel's API
The missing-team check ran in team(), so a board({ fetch }) with credentials of its own, which can use their default team, failed with missing_team in any GitHub Actions job. It now runs where the job's token is sent, and that same place sends the token only to Vercel's API, which it's made out to: a vercel({ api }) pointing anywhere else fails with wrong_audience before GitHub is asked for one.
Vercel's API now takes a GitHub Actions run's team by slug as well as by ID, so the CI guide, the CLI reference, SPEC, and the missing-team hint say --scope <team>.
This reverts commit 40b333e.
There was a problem hiding this comment.
Read the diff; CI is green. The client side looks right to me: the token only goes to api.vercel.com, it's cached until a minute before exp and dropped on failure, a missing team fails before GitHub is asked for a token, and the grant hint quotes the board name. Two things to look at, neither blocking:
- The job's OIDC token now beats
VERCEL_AUTH_TOKEN.asGithubActions()sits above the login, so any job withid-token: writethat already sendsVERCEL_AUTH_TOKENswitches to the workflow principal.id-token: writeis common for npm provenance and AWS. On upgrade, those jobs stop acting as the user and hitboard_not_granted/missing_teamuntil someone adds a--githubgrant. The test atvercel-github-actions.test.ts:68makes this deliberate. If you keep it, it should go in the changeset as a behavior change. Otherwise, putting an explicitVERCEL_AUTH_TOKENahead of the job token keeps those workflows working as before. githubTokenGoesToalso acceptshttp://localhost|127.0.0.1. That's a test hook in shipped code. It's low risk because the audience pins the token to Vercel's API, but it would be tidier to inject the allowed origin through the test's environment.
… job's OIDC token A job with id-token: write often has it for something else (npm provenance, cloud OIDC), so a workflow that already sets VERCEL_AUTH_TOKEN keeps acting as that login. Co-authored-by: Julian Benegas <40034115+julianbenegas@users.noreply.github.com>
An issuer like GitLab.com signs tokens for every customer it serves under one iss, so a grant for a claim like ref=main let in anyone's job. sub is unique within an issuer and never reassigned, so every oidc grant names one: exact, or a prefix whose * follows a : or /. Removals don't need one, so an older grant can still be taken apart.
There was a problem hiding this comment.
Approving at Julian Benegas's request. I read the full diff at c3c52e3, including the three new commits that require sub on oidc grants. CI is green. One of the commits is mine (VERCEL_AUTH_TOKEN going ahead of the job's token).
Not blocking, but worth a follow-up: subPrefix only requires one character before the : or /, so sub=project_path:* (or repo:*) passes validation. On gitlab.com that still matches every project, which is the case this change is meant to close. An extra claim like project_id narrows it, but nothing requires one. Requiring at least two segments in the pattern would close it, as would refusing a prefix that is only the issuer's own claim-type label.
GitHub Actions workflows use the team's board in Vercel's API with the job's own OIDC token, no stored secret, and grants there name a repository's runs or an issuer.
permissions: id-token: write,vb,board(), and avercel boardwith no Vercel login send GitHub's OIDC token to Vercel's board (source GitHub Actions OIDC); with no--scopeorVERCEL_ORG_IDthey fail with reasonmissing_scope.grants create,update, andexplainwith--githubor--oidcreach Vercel's API instead of a client-side refusal.oidcgrant names the workload bysub, on any board: an issuer signs tokens for everyone it serves, andsubis the one claim OIDC gives no two of them. Eachsubis exact or a prefix ending in*right after a:or/(project_path:acme/api:*), soacmenever reachesacme-evil. A grant withoutsub, or with a*elsewhere in it, is 400invalid_grant; removing a principal from an older grant still works.subPrefixis exported from@vercel/board/access. A mention of a workflow by ID (@[github:repo:<id>]) is found by its handle.vercel()reads two new API principals,githubandoidc(actor kindworkflow), and passes the API'sunsupported_principalthrough as it is.whoami, and its errors. The fake now keeps and explains GitHub and OIDC grants and names their callers as Vercel's API will. Vercel's API side isn't live yet.Users
From the CLI in process, against the fake Vercel API, in a job with
VERCEL_ORG_ID=team_test:With nothing naming the team (
--namewithout--scopeorVERCEL_ORG_ID):grants create --githubonmain, then against an API that still refuses it, on this branch:Protocol / backends
board_not_grantedwith the--githubgrant to create, and makes no board.Open
vercel boardfor the team's board, which needs a Vercel CLI release that runs it with no login: it then hands board none, so the job's token goes. A board of your own atBOARD_URLkeepsvb.via:github:repo:<id>alone doesn't say its repository.