GitHub Actions OIDC lets a workflow trade a short-lived, signed JWT from GitHub for temporary cloud credentials, so you can delete the long-lived AWS access keys, GCP service account JSON keys and Azure client secrets sitting in your repository secrets. You need three things: permissions: id-token: write in the workflow, a trust relationship in the cloud that checks the token's claims, and the official login action for that cloud. The part people get wrong is the claim check, and since July 15, 2026 the default sub claim format has changed for new repositories, which breaks a lot of copy-pasted trust policies.
Why CI Keys Are the Non-Human Identity to Fix First
Most non-human identity (NHI) programs start with an inventory of service accounts, API keys and tokens. CI credentials are usually the worst entries on that list: they are long-lived, highly privileged (they deploy production), copied into many repositories, and readable by any workflow step, including third-party actions you did not write. Rotating them is manual, so it rarely happens.
OIDC workload identity federation removes the stored secret entirely. Each job gets a token that is valid for minutes, bound to a specific repository, branch or environment, and auditable in CloudTrail, Cloud Audit Logs or Entra sign-in logs. If you are evaluating platforms to manage the rest of your machine identities, our roundup of NHI and machine identity management tools covers the inventory side; this guide is the concrete fix for the CI slice.
How the GitHub OIDC Token Works
When a job has id-token: write, the runner can request a JWT from GitHub's issuer, https://token.actions.githubusercontent.com. The flow is:
- The login action requests a token with an audience the cloud expects.
- GitHub signs a JWT whose claims describe the run: repository, ref, environment, workflow and more.
- The action sends the JWT to the cloud's token service (AWS STS, Google STS, Microsoft Entra ID).
- The cloud validates the signature against GitHub's published keys, checks your configured conditions, and returns short-lived credentials.
The claims you will actually use in trust conditions, from GitHub's OIDC reference:
| Claim | Example | Use it for |
|---|---|---|
iss |
https://token.actions.githubusercontent.com |
Fixed issuer; configured on the cloud provider |
aud |
sts.amazonaws.com |
Audience; defaults to the repository owner's URL unless the action sets one |
sub |
repo:octo-org/octo-repo:environment:Production |
Primary match: repo plus branch, tag, environment or PR |
repository |
octo-org/octo-repo |
Human-readable, but names can be reused |
repository_id, repository_owner_id |
456789, 123456 |
Immutable numeric IDs; prefer these |
ref |
refs/heads/main |
Branch or tag |
environment |
production |
Present only when the job declares an environment |
job_workflow_ref |
octo-org/infra/.github/workflows/deploy.yml@refs/heads/main |
Pin deploys to a reusable workflow |
event_name, runner_environment |
push, github-hosted |
Extra guards |
The default sub depends on the job's context:
| Context | Default sub (name-based format) |
|---|---|
Job with environment: production |
repo:ORG/REPO:environment:production |
pull_request event |
repo:ORG/REPO:pull_request |
| Branch | repo:ORG/REPO:ref:refs/heads/main |
| Tag | repo:ORG/REPO:ref:refs/tags/v1.2.0 |
The 2026 change: immutable subject claims
GitHub announced that the default sub now embeds the numeric owner and repository IDs, for example repo:octo-org@123456/octo-repo@456789:ref:refs/heads/main. The goal is to stop a recycled organization or repository name from minting tokens that match an old trust policy. The rollout rules:
- Repositories created after July 15, 2026 use the immutable format automatically.
- Repositories renamed or transferred after July 15, 2026 also switch.
- Older repositories keep the name-based format until you opt in at the repository or organization level (UI toggle, or the
use_immutable_subjectfield on the OIDC REST endpoints). - GitHub Enterprise Server is not affected.
The practical consequence: a trust policy written for repo:my-org/my-repo:* will not match tokens from a new repository, and the error looks exactly like any other trust failure. To see what your repository emits and to get its IDs:
# Numeric IDs to use in conditions
gh api repos/acme/payments-api --jq '.id, .owner.id'
# Current sub template for the repo (the response includes sub_claim_prefix)
gh api repos/acme/payments-api/actions/oidc/customization/sub
The examples below use the immutable format with owner acme (ID 5544123) and repository payments-api (ID 821093847). If your repository still emits the name-based format, drop the @ID parts from sub, but keep the separate ID conditions.
The Workflow Side: id-token Permission
Every cloud needs the same permission. Grant it at job level, only on jobs that deploy:
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v7
# cloud login step goes here
Setting permissions sets every scope you do not list to no access, which is why contents: read is listed explicitly for actions/checkout. Using environment: production is deliberate: it changes the sub to the environment form, and GitHub environments support required reviewers and deployment branch rules, so the cloud trust and the human approval gate line up.
AWS: IAM OIDC Provider and Role Trust Policy
Create the identity provider once per account. AWS no longer needs a certificate thumbprint for GitHub; the configure-aws-credentials README states that a thumbprint, if specified, is ignored.
aws iam create-open-id-connect-provider \
--url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.com
Then create a role with a trust policy scoped to one repository and one environment. Since February 2026, AWS STS can validate GitHub-specific claims such as repository_id, repository_owner_id, job_workflow_ref, ref and environment as condition keys, which lets you pin the numeric IDs even on repositories still using the old sub format:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:acme@5544123/payments-api@821093847:environment:production",
"token.actions.githubusercontent.com:repository_id": "821093847",
"token.actions.githubusercontent.com:repository_owner_id": "5544123"
}
}
}
]
}
The workflow step, using the current major version (v6.3.0 was the latest release as of November 2026):
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::111122223333:role/gha-payments-api-prod
aws-region: us-east-1
- run: aws sts get-caller-identity
Credentials default to a one-hour session; role-duration-seconds accepts 900 to 43200, but the role's maximum session duration must allow it. Keep it short.
GCP: Workload Identity Federation Pool and Provider
Google's model has two layers: an attribute condition on the provider decides which tokens may enter the pool at all, and IAM bindings decide what an admitted identity can do. Always set the condition. The google-github-actions/auth security notes recommend the numeric *_id claims for exactly the name-reuse reason above.
gcloud iam workload-identity-pools create "github" \
--project="${PROJECT_ID}" \
--location="global" \
--display-name="GitHub Actions"
gcloud iam workload-identity-pools providers create-oidc "payments-api" \
--project="${PROJECT_ID}" \
--location="global" \
--workload-identity-pool="github" \
--issuer-uri="https://token.actions.githubusercontent.com" \
--attribute-mapping="google.subject=assertion.sub,attribute.repository_id=assertion.repository_id,attribute.repository_owner_id=assertion.repository_owner_id,attribute.ref=assertion.ref" \
--attribute-condition="assertion.repository_owner_id == '5544123' && assertion.repository_id == '821093847' && assertion.ref == 'refs/heads/main'"
gcloud iam service-accounts add-iam-policy-binding "deployer@${PROJECT_ID}.iam.gserviceaccount.com" \
--project="${PROJECT_ID}" \
--role="roles/iam.workloadIdentityUser" \
--member="principalSet://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/github/attribute.repository_id/821093847"
Any claim you reference in a condition or binding must be mapped to an attribute first. The workflow step, with google-github-actions/auth@v3:
- uses: google-github-actions/auth@v3
with:
workload_identity_provider: projects/123456789/locations/global/workloadIdentityPools/github/providers/payments-api
service_account: deployer@my-project.iam.gserviceaccount.com
You can also skip the service account and grant roles directly to the principalSet (direct workload identity federation), but not every Google Cloud API accepts federated principals, so impersonation is the safer default. Note that Google Cloud caps mapped attributes at 127 bytes; google.subject=assertion.sub with a long repository and branch name can exceed it, and the immutable format makes sub longer.
Azure: Federated Credential on a Managed Identity
On Azure you add a federated identity credential to either an app registration or a user-assigned managed identity. The managed identity route avoids creating an app registration and a service principal you then have to govern.
az identity create --name gha-payments-api-prod --resource-group rg-deploy
az identity federated-credential create \
--name github-payments-api-production \
--identity-name gha-payments-api-prod \
--resource-group rg-deploy \
--issuer "https://token.actions.githubusercontent.com" \
--subject "repo:acme@5544123/payments-api@821093847:environment:production" \
--audiences "api://AzureADTokenExchange"
Then assign an Azure role to the identity's principal ID at the narrowest scope that works, usually a resource group. Azure is strict in useful ways: per the Microsoft Entra documentation, the subject must match exactly, wildcards are not supported in any credential property, and an identity holds at most 20 federated credentials. A credential with a typo is created without error and only fails at login. Microsoft also documents a migration path to immutable subjects: add a second credential for the new subject, opt the repository in, verify, then delete the old one.
The workflow step, with azure/login@v3:
- uses: azure/login@v3
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
None of these three values is a secret, which is the point. The action's README warns against feeding untrusted values such as github.event fields into these inputs.
The Misconfiguration That Matters: Wildcard Subjects
The most common real-world bug is a sub condition so broad that repositories or branches you never intended can assume the role. AWS now rejects trust policies for the GitHub provider that omit the sub key or set it to only a wildcard, but it still accepts patterns that are dangerously wide.
Bad, and accepted by IAM:
"Condition": {
"StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
"StringLike": { "token.actions.githubusercontent.com:sub": "repo:acme*" }
}
repo:acme* matches repo:acme-research/anything and any other organization whose name starts with acme, including one an attacker registers. repo:acme/* is better but still lets every repository and branch in the org, including a feature branch anyone with write access can push, assume your production role.
Good:
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:acme@5544123/payments-api@821093847:environment:production",
"token.actions.githubusercontent.com:repository_id": "821093847"
}
}
| Pattern | Who can assume the role | Verdict |
|---|---|---|
No sub condition |
Any GitHub repository anywhere | Rejected by IAM today; audit old roles |
repo:acme* |
Any org whose name starts with acme |
Never |
repo:acme/* |
Every repo and branch in the org | Only for read-only roles |
repo:acme/app:* |
Every branch, tag and PR context of one repo | Too wide for prod |
...:environment:production plus ID conditions |
Jobs in one repo gated by environment rules | Recommended |
Also avoid ForAllValues: operators in Allow statements; the action README warns they evaluate to true when the claim is missing.
Hardening Checklist
- One role or identity per repository and environment; never share a production role across repositories.
- Require reviewers and restrict deployment branches on the
productionenvironment. - For platform teams, require
job_workflow_refto equal your central reusable deploy workflow so application repos cannot hand-roll a deploy. - Never grant
id-token: writeto workflows triggered bypull_request_targetor other events that run untrusted code with base-repository privileges. - Pin third-party actions to a full commit SHA; any step in the job can request the token.
- Delete the old access keys and JSON keys after cutover, and alert on any new ones. The same secretless pattern applies to package publishing; see npm trusted publishing.
If you are editing trust policies by hand, run them through a JSON formatter before applying; a stray comma is the most common reason a policy update fails.
Troubleshooting Common Errors
| Error text | Cloud | Usual cause | Fix |
|---|---|---|---|
Not authorized to perform sts:AssumeRoleWithWebIdentity |
AWS | sub, aud or ID condition does not match the token, often the immutable-format switch |
Compare the policy with the actual claims; update sub to the @ID form |
No OpenIDConnect provider found in your account |
AWS | Provider missing in this account or URL mismatch | Create the provider for https://token.actions.githubusercontent.com |
It looks like you might be trying to authenticate with OIDC. Did you mean to set the `id-token` permission? |
AWS (action log) | Job lacks id-token: write |
Add the permission at job level |
AADSTS700213: No matching federated identity record found for presented assertion subject |
Azure | Subject mismatch, including name-based versus immutable format | Copy the exact subject from the run log's federated token details |
AADSTS7002138 (matches with case-insensitive comparison only) |
Azure | Casing differs between credential and token | Match casing exactly |
The size of mapped attribute exceeds the 127 bytes limit. |
GCP | Long sub mapped to google.subject |
Shorter names, or map a shorter claim |
The issuer in ID Token ... does not match the expected ones |
GCP | Wrong issuer URI, or GitHub Enterprise Cloud with a custom issuer | Fix --issuer-uri |
GitHub's actions-oidc-debugger prints the decoded claims of a real token; run it only in a private repository.
Frequently Asked Questions
Should I keep the old access keys as a fallback?
No. A fallback key is the same long-lived secret you set out to remove, and it will be the one that leaks. Run both paths for a few days while you verify OIDC in every workflow, then deactivate the keys, watch for failures, and delete them. If other systems still need static secrets, put them in a proper vault; our comparison of secret management tools is a starting point.
Do I still need a thumbprint for the AWS OIDC provider?
No. The configure-aws-credentials documentation says the thumbprint is no longer necessary and is ignored if specified. Older Terraform modules and blog posts still set one, which is harmless but unnecessary.
Will the immutable subject change break my existing deployments?
Not by itself for repositories created before July 15, 2026, because they keep the name-based format until you opt in. It will break trust policies when you create a new repository, rename or transfer one, or opt in without updating the cloud side first. Add the new subject alongside the old one, opt in, verify, then remove the old match.
Can I use OIDC with self-hosted runners?
Yes. The token comes from GitHub, not the runner, so the same trust policies apply. Consider adding a runner_environment check where your cloud supports that claim, and remember that a compromised self-hosted runner can request tokens for any job it runs.
How long do the credentials last?
The GitHub OIDC token itself is short-lived; the auth action's documentation notes it expires in about five minutes. The cloud credentials you get back last as long as you configure: one hour by default for AWS, and service-specific defaults for GCP and Azure access tokens.
Bottom Line
GitHub Actions OIDC is the single highest-leverage NHI fix most teams can ship in a day: no stored cloud secrets, credentials that expire in an hour or less, and trust that is checked on every run. Use the current actions (aws-actions/configure-aws-credentials@v6, google-github-actions/auth@v3, azure/login@v3), scope trust to one repository and one environment with numeric IDs, and write your conditions for the immutable sub format now, because every repository you create from here on already uses it.