Registry authentication and least privilege
A CI job that only validates a pull request does not need registry write access. Publishing needs a distinct trust boundary: the approved repository and target registry, a narrowly scoped identity, and a credential with a bounded lifetime. Separate pull, push and deploy rights instead of sharing one administrative token.
Worked example
Work offline: the scenarios and evidence are synthetic. Do not run hosted workflows, contact registries, use real credentials or deploy anything for this lesson. Keep the exercise offline. Before any separately authorized runtime check, verify the effective daemon, builder, runner or deployment identity as applicable; use synthetic data, reviewed inputs and bounded resources. Record missing evidence as NOT RUN.
Fictional permission matrix (not an IAM policy)PR validation : contents read; registry write denied; deploy deniedRelease job : contents read; push to approved image repository onlyDeploy job : pull approved digest; deploy to approved environment onlyOIDC : token request -> provider trust check -> short-lived credentialGitHub Actions permissions controls the workflow token; it does not itself configure external registry authorization. A provider that supports OIDC can exchange an identity token for a narrowly scoped credential. id-token: write allows requesting an identity token, not automatic registry or cloud write access. Configure the provider to validate issuer, audience and the intended repository/ref or environment according to its supported claims. For token-based registry login, use an approved secret store and never print the value; a noninteractive --password-stdin login reduces exposure in command arguments but does not make the runner or credential store safe. Reserve publishing for reviewed changes, restrict token scope, use short-lived credentials when supported, and clean up credentials on a disposable runner. No real authentication is required here. Treat the permission matrix as intended policy, not proof of enforcement. In a separately authorized integration test, require a successful permitted operation and an expected authorization denial; a network or TLS error is not proof of denial. OIDC trust and issued credential scope must both be checked.
Common mistake
An OIDC token is not a permission policy, and a secret masked in logs is not necessarily safe from code running in that job.
Manual practice
An organization has a test job, an image publishing job and a staging deploy job. Assign the minimum permissions from the matrix and explain why the test job cannot publish.
Worksheet: lab-fixtures/docker-ci-cd/02-registry-credentials/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Registry authentication and least privilege — Knowledge check
Apply release and CI/CD reasoning to a fictional scenario.
Which job needs registry write rights?
What does id-token: write grant?
Which credential design reduces impact if a publishing token is exposed?