Keyless CI with GitHub Actions
Let GitHub Actions workflows act as a Prism service account by exchanging GitHub's OIDC token for a Prism token, so no Prism API key is stored in GitHub secrets.
Overview
GitHub Actions can issue each job a signed OIDC token describing the repository, branch
and triggering event. Prism trusts GitHub's issuer per project, and a service account
declares which repositories and events may assume it. The job then exchanges its GitHub
token at POST /api/v1/auth/service-accounts/assume/openid and receives a
24-hour Prism token for the service account.
From there the job can do anything the service account is granted: read store values, mint federation tokens for AWS or GCP, or get SSH certificates for deployment.
Prerequisites
- A Prism project and a logged-in admin CLI profile
- A GitHub repository, e.g.
acme-corp/payments
-
Trust GitHub Actions in the project
The issuer and JWKS URL are preconfigured; a project can have one GitHub Actions trust.
prism projects openid-trusts create --project payments --kind github-actions # name: github-actions # issuer: https://token.actions.githubusercontent.com # audience: https://acme.id.prism.example.comNote the
audience: the workflow must ask GitHub for a token with exactly this audience. Tokens with GitHub's default audience are rejected, so a token minted for another relying party cannot be replayed against Prism. -
Create the service account and allow the repository to assume it
--organizationis the GitHub owner,--repothe repository name without the owner, and--eventthe triggering events allowed. Both--repoand--eventcan be repeated; all values match exactly.prism service-accounts create -p payments -n deployer prism service-accounts assumptions add-github-actions -p payments \ --service-account deployer \ --organization acme-corp \ --repo payments \ --event push --event workflow_dispatch prism service-accounts assumptions list -p payments --service-account deployerPull requests from forks run with the
pull_requestevent; leave it out unless untrusted code should get this identity. -
Grant the service account what CI needs
# e.g. read deployment configuration prism stores add-grant -p payments --store app-config \ --principal deployer --effect allow --role prism:store-reader --key-prefix prod/ -
Exchange the token in the workflow
The job needs
id-token: writeto request a GitHub OIDC token:name: deploy on: push: branches: [main] permissions: id-token: write contents: read env: PRISM_SERVER_URL: https://prism.example.com PRISM_AUDIENCE: https://acme.id.prism.example.com # audience of the trust jobs: deploy: runs-on: ubuntu-latest steps: - name: Get a Prism token run: | GH_TOKEN=$(curl -fsS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=$PRISM_AUDIENCE" | jq -r .value) PRISM_TOKEN=$(curl -fsS -X POST "$PRISM_SERVER_URL/api/v1/auth/service-accounts/assume/openid" \ -H 'Content-Type: application/json' \ -d "$(jq -n --arg t "$GH_TOKEN" \ '{project: "payments", service_account: "deployer", token: $t}')" \ | jq -r .token) echo "::add-mask::$PRISM_TOKEN" echo "PRISM_TOKEN=$PRISM_TOKEN" >> "$GITHUB_ENV" - name: Read deployment config run: | curl -fsS -H "Authorization: Bearer $PRISM_TOKEN" \ "$PRISM_SERVER_URL/api/v1/payments/stores/app-config/values/prod%2Fdatabase-url" \ -o db-url.txtWith the
prismCLI installed on the runner, the exchange is one command, and the token is saved to the CLI profile:echo "$GH_TOKEN" > gh-token.jwt prism auth sa-assume-openid --project payments --service-account deployer --token-file gh-token.jwt prism stores values get prod/database-url -p payments --store app-config
Troubleshooting
"the project must trust github_actions first"
Create the trust (step 1) before adding the assumption method.
"unauthorized" when exchanging the token
Usually the audience. Decode the GitHub token's payload and compare aud with
the trust's audience (prism projects openid-trusts list --project payments).
"forbidden" when exchanging the token
The token is valid but no assumption method matches. Compare the token's
repository_owner, repository and event_name claims
with the method's organization, repositories and events.
Security considerations
- Prefer one service account per repository (or per deployment target) with only the grants it needs.
- Allow only the events you need;
pushandworkflow_dispatchare limited to people with write access,pull_requestis not. - Each exchange is audit logged; review them with
prism org audit --org acme.