What are the `sub` claim formats, and which do you put in an AWS trust policy?
AdvancedConceptOIDC & Security Hardening
Answer
- Branch push:
repo:ORG/REPO:ref:refs/heads/main - Tag:
repo:ORG/REPO:ref:refs/tags/v1.4.0 - Environment job:
repo:ORG/REPO:environment:prod(replaces the ref form) - Pull request:
repo:ORG/REPO:pull_request
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:devopsshack/shack-api:environment:prod"
}
}
Use StringLike only for deliberate wildcards like repo:devopsshack/shack-api:ref:refs/tags/v*. Never repo:devopsshack/* for a prod role. Orgs can customize the sub template (for example, to include job_workflow_ref) via the OIDC customization API.
More on OIDC & Security Hardening
How does GitHub OIDC work, end to end?IntermediateConfigure OIDC to AWS: provider, role and workflow.AdvancedConfigure OIDC to Azure.AdvancedConfigure OIDC to GCP.AdvancedWhy pin actions to a full commit SHA, and how do you keep pins updated?IntermediateWhat is script injection, and how do you fix it?Advanced