Lab: DevOps identities, permissions, OIDC, and Key Vault
Outcome
Select an identity from its runtime boundary, configure GitHub and Azure DevOps least access, use OIDC federation instead of a stored cloud secret, and retrieve a Key Vault secret/certificate through authorized workload identity.
Do
- Make a one-page identity decision for four cases: service principal for a non-Azure workload; system-assigned managed identity tied to one Azure resource; user-assigned managed identity shared by selected Azure workloads; and OIDC federation for GitHub Actions/Azure Pipelines. Assign only a training resource-group role.
- In GitHub, run a workflow with explicit minimal
permissions, compare the temporaryGITHUB_TOKEN, GitHub App installation token, and short-lived PAT for a one-off legacy action. Give a test outside collaborator only the required repository role and environment deployment permission; remove invitation afterward. In Azure DevOps, create a project/team, area/iteration, and security group; compare Stakeholder versus Basic access and verify least privilege. - Create a resource-group-scoped Azure Resource Manager service connection using workload identity federation. Authorize only the training pipeline, add the issuer/subject/audience federated credential, and deploy a harmless tag. In GitHub, configure Azure OIDC with
id-token: writeand a subject restricted to the training repo/branch/environment. Keep PATs short-lived, minimum-scope, and outside pipeline automation. - Create a Key Vault, assign the runtime identity only the Key Vault data role required for one training secret/certificate operation, and retrieve it at runtime without printing values. Rotate a test secret/certificate reference and verify the workload uses the intended version.
Verify
Capture the identity decision, effective GitHub/Azure DevOps permissions, project/team boundary, federated credential subject/audience, successful OIDC deployment, service-connection pipeline authorization, Key Vault role, and secret/certificate retrieval without value exposure. You should now understand: an identity authenticates a workload, a role authorizes it, OIDC exchanges short-lived assertions, and a service connection constrains a pipeline’s use of that identity.
Break and fix
- Run with mismatched OIDC subject/audience or missing
id-token: write; inspect token/federated-credential error, correct only the claim/permission, and retry. - Reference an unauthorized service connection or Key Vault secret; inspect pipeline authorization and data-plane role separately, grant the narrow missing right, then remove it.
- Give a test user broad admin/PAT scope; replace it with a role/group, least scope/expiry, and offboard the user.
Scenario practice
- Configure: Choose service principal, system/user-assigned identity, GitHub App, GITHUB_TOKEN, PAT, or OIDC for a stated owner/runtime/resource boundary.
- Diagnose: A pipeline cannot authenticate or read a secret. Inspect claims, service-connection authorization, Azure role, Key Vault data role, secret version, and log masking.
- Distinguish: Contrast identity, role, service connection, PAT, GitHub App, GITHUB_TOKEN, environment permission, and Key Vault secret/key/certificate.
Clean up
Remove test identity roles, federated credentials, service connections, pipeline authorization, Key Vault objects, project/team invitations, and training resource group.
Sources and re-audit
- Azure Resource Manager service connections, checked 2026-08-22.
- Azure DevOps workload identity, checked 2026-08-22.
- GitHub OIDC in Azure, checked 2026-08-22.
Re-audit when identity, federation, service-connection, GitHub token, or Key Vault behavior changes.
Related
service-account · managed-identity · service-principal · service-connection · key-vault · All labs