OIDC and Short-Lived Access
Identity instead of stored cloud keys
A workflow may need limited access to a cloud resource. OpenID Connect (OIDC) allows a job to request an identity token and present it to a trusted external provider. The provider validates the token and trust policy, then may issue short-lived access credentials. The GitHub workflow token and cloud credentials are different. Short lifetime reduces exposure but does not eliminate misuse.
Grant the narrow permission
This is an illustrative fragment, not a runnable workflow. id-token: write allows requesting an OIDC token; it does not grant write access to cloud resources. The cloud role controls resource permissions. Scope the permission to the job needing identity and omit contents: read if the job does not need repository contents. Never print tokens, include them in artifacts or issue them for unreviewed code.
# Fragment only: permission declaration for a reviewed deployment job.permissions: contents: read id-token: writeUnderstand trust claims
The issuer identifies the token service; the audience identifies intended recipients; the subject describes identity context, for example repository and environment. A provider must validate signatures, expiry, issuer, audience and allowed subject using its supported implementation. Example mock subject repo:demo/garden:environment:production-demo is deliberately exact. Default subject shapes vary with environment and events; custom claims and provider support differ. Use a reviewed provider-specific trust policy, not a broad wildcard.
Offline reasoning practice
The lab compares plain fictional claim dictionaries after an assumed external verification flag. It rejects wrong issuer, audience, subject, expiration and missing verified flag. These dictionaries are not JWTs; the model is not authentication code and does not validate cryptography. Predict: a valid identity for staging must not automatically assume the production role. No token request, cloud exchange or credential access occurs.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
OIDC and Short-Lived Access — knowledge check
Reason about reliable delivery and trust boundaries.
What does id-token: write enable?
Which claim identifies intended recipients?
Can a staging subject automatically assume production identity?
What is missing from a mock claim comparison?
How should real credentials be handled?