Skip to content

Conditional Access and Workload Identities

github-actions[bot] edited this page Nov 29, 2026 · 2 revisions

Last reviewed: 2026-11-28 (provider and GitHub documentation only; no policy was created or changed in any tenant, account or organization)

Prerequisites: Cloud identity index ยท Phishing-resistant authentication ยท AWS IAM policy evaluation

๐ŸŽฏ Purpose

Describe the policy layers that sit above an identity's own permissions (Entra Conditional Access, AWS Organizations policies and permissions boundaries, Google Cloud context-aware access), and how to replace long-lived CI/CD secrets with workload identity federation that trusts only the right pipeline.

โš™๏ธ Function

Lists what each provider's control can and cannot enforce, then gives documented trust configurations for GitHub Actions OIDC in Entra ID, AWS IAM and Google Cloud, with the sub and aud values that each provider checks.

๐Ÿ† Goal

Access decisions that depend on more than a password, and pipelines that authenticate with short-lived tokens bound to one repository, branch or environment.

๐Ÿ“‹ When To Use

  • Designing Conditional Access or organization guardrail policies
  • Removing stored cloud keys from CI/CD systems
  • Reviewing an existing OIDC trust that might accept tokens from repositories you do not own

๐ŸŸฆ Microsoft Entra Conditional Access

  • Licensing: Conditional Access needs Microsoft Entra ID P1 (or Microsoft 365 Business Premium). Risk-based policies need P2 (ID Protection) (overview).
  • Authentication strengths: require "Phishing-resistant MFA strength" for administrators and sensitive apps. The grant Require authentication strength cannot be combined with Require multifactor authentication in one policy (authentication strengths). See phishing-resistant authentication.
  • Exclusions: exclude the emergency access group from policies that block or restrict sign-in; report-only policies need no exclusion (emergency access).
  • Continuous access evaluation (CAE): has standard location enforcement and a strict location enforcement mode (public preview). Teams calls and chat do not honor IP-based policies (CAE).
  • Changes are audited under the Policy category: "Add Conditional Access policy", "Update Conditional Access policy", "Delete Conditional Access policy", "Add named location", "Update continuous access evaluation", "Update security defaults" (audit activities). Alert on these: a weakened policy is a common persistence step.
  • Sign-in evidence: SigninLogs columns ConditionalAccessStatus (success, failure, notApplied) and ConditionalAccessPolicies show what was applied to each sign-in (SigninLogs reference).

Conditional Access For Workload Identities

From Conditional Access for workload identities:

  • Creating or changing these policies needs Workload Identities Premium.
  • It applies only to single-tenant service principals registered in your tenant. Managed identities and multitenant (SaaS) apps are not covered.
  • Conditions are location and service principal risk; the only grant control is Block access.

๐ŸŸง AWS Guardrails

Control What it limits Documented limits
Service control policy (SCP) The maximum permissions of principals in member accounts Never grants permissions
Resource control policy (RCP) The maximum permissions on resources in member accounts, including access by external principals and root users Needs Organizations with all features; never grants permissions; does not affect resources in the management account or service-linked roles; supported services include S3, STS, KMS, Secrets Manager, SQS and others (RCPs)
Permissions boundary The maximum permissions an identity-based policy can grant to one IAM user or role Does not grant permissions; effective permissions are the intersection with identity policies (and SCPs, session policies); an implicit deny in a boundary does not limit some resource-based policy grants (permissions boundaries)

AWS's permissions-boundary delegation example uses the iam:PermissionsBoundary condition key so that a delegated administrator can create users only when a named boundary policy is attached. Pair it with a deny on iam:DeleteUserPermissionsBoundary so the boundary cannot be removed.

IAM Identity Center

Human access to accounts should come through IAM Identity Center permission sets rather than IAM users. For fast removal, AWS recommends pre-deploying an SCP that denies everything for listed Identity Center user IDs, using identitystore:userId rather than aws:userId (prerequisites for revoking permissions):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "identitystore:userId": ["<identity-center-user-id-placeholder>"]
        }
      }
    }
  ]
}

Keep a user ID in the policy for at least 12 hours after adding it.

๐ŸŸฉ Google Cloud Context-Aware Access

Access Context Manager defines access levels: basic levels (IP CIDR ranges, device, user identity) or custom levels written in CEL. It does not enforce anything by itself; enforcement points are VPC Service Controls, Identity-Aware Proxy, Context-Aware Access for Workspace and IAM Conditions. Device attributes need a paid enterprise security subscription.

Organization policies add guardrails for workload credentials: iam.disableServiceAccountKeyCreation is enforced by default for organizations created on or after May 3, 2024 (create and delete keys).

๐Ÿค– Workload Identity Federation For GitHub Actions

Federation lets a pipeline exchange a short-lived OIDC token for cloud credentials, so no cloud secret is stored in the CI system. The risk moves to the trust condition: by default GitHub uses one issuer (https://token.actions.githubusercontent.com) for every organization (GitHub Enterprise Cloud can opt in to an enterprise-specific issuer URL), so a condition that does not pin your organization and repository lets other GitHub users' workflows in.

GitHub Subject Formats

From GitHub's OIDC reference:

Trigger sub claim
Job that references an environment repo:ORG-NAME/REPO-NAME:environment:ENVIRONMENT-NAME
Branch repo:ORG-NAME/REPO-NAME:ref:refs/heads/BRANCH
Pull request (job without an environment) repo:ORG-NAME/REPO-NAME:pull_request
Immutable format (default for repositories created after July 15, 2026) repo:OWNER@OWNER-ID/REPO@REPO-ID:ref:refs/heads/BRANCH
  • Repositories created before July 15, 2026 keep the old format unless they opt in at organization or repository level; renames and transfers after that date also switch. Immutable subjects are not available on GitHub Enterprise Server. Microsoft has an Entra migration guide.
  • The Entra trust documentation writes the pull-request subject as pull-request (hyphen); GitHub's own reference uses pull_request (underscore). Trust GitHub's format and check against a real token from your workflow.
  • The trust examples below use the name-based format. For a repository on the immutable format, the sub value must include the IDs (for example repo:example-org@123456/example-repo@456789:ref:refs/heads/main), or the exchange fails.
  • Avoid trusting pull_request subjects for deploy or privileged roles: that subject is issued to workflows running proposed changes that have not been reviewed and merged.

Microsoft Entra Federated Identity Credential

Issuer, subject and audience must match the token case-sensitively (workload identity federation); an FIC has exactly one audience, and only RS256-signed issuers are supported (considerations). Microsoft's create-trust example, with reserved names:

# credential.json describes the trust; values here are placeholders
az ad app federated-credential create --id <application-object-or-client-id> --parameters credential.json
{
  "name": "example-repo-production",
  "issuer": "https://token.actions.githubusercontent.com",
  "subject": "repo:example-org/example-repo:environment:Production",
  "description": "GitHub Actions production environment",
  "audiences": ["api://AzureADTokenExchange"]
}

Flexible FICs, which add a matches operator with wildcards for GitHub, GitLab and Terraform Cloud, are in preview (flexible FICs). If you use one, pair the wildcard with a numeric claim such as repository_id.

AWS IAM Role Trust Policy

Audience is sts.amazonaws.com. IAM refuses to create or update a GitHub trust policy whose token.actions.githubusercontent.com:sub condition is missing or is only *, ? or null (create a role for OIDC). It still accepts broad patterns such as repo:example-org/*, so pin the repository and branch or environment:

{
  "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:example-org/example-repo:ref:refs/heads/main"
        }
      }
    }
  ]
}

For HCP Terraform, app.terraform.io:sub is required and STS denies requests from roles whose trust policy does not evaluate it. The detection aws_cloudtrail_assume_role_web_identity_unexpected_subject.yml alerts on AssumeRoleWithWebIdentity events whose responseElements.subjectFromWebIdentityToken is not on an allowlist.

Google Cloud Workload Identity Federation

Google states that for GitHub, GitLab SaaS and HCP Terraform you "must use an attribute condition that restricts access to tokens issued by your GitHub organization" (deployment pipelines). Note the trailing slash on the documented issuer URI:

gcloud iam workload-identity-pools create POOL_ID \
  --location="global" \
  --description="DESCRIPTION" \
  --display-name="DISPLAY_NAME"

gcloud iam workload-identity-pools providers create-oidc PROVIDER_ID \
  --location="global" \
  --workload-identity-pool="POOL_ID" \
  --issuer-uri="https://token.actions.githubusercontent.com/" \
  --attribute-mapping="google.subject=assertion.sub" \
  --attribute-condition="assertion.repository_owner=='example-org' && assertion.ref=='refs/heads/main'"

Grant access to a principal set such as principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/attribute.ATTRIBUTE_NAME/ATTRIBUTE_VALUE, or let it impersonate a service account through roles/iam.workloadIdentityUser. Google's best practices recommend immutable attributes; GitHub's numeric repository_id and repository_owner_id claims do not change on rename, unlike names that can be re-registered.

Trust Review Checklist

  • The audience is the provider's documented value (api://AzureADTokenExchange, sts.amazonaws.com, or the pool provider's audience).
  • The subject or condition pins organization and repository, and a branch or protected environment for deploy roles.
  • No privileged role trusts pull_request subjects.
  • Wildcards, where used, are paired with numeric ID claims.
  • Trusts are re-checked after a repository rename or transfer and when moving to immutable subjects.
  • Federated sign-ins are monitored (Entra AADServicePrincipalSignInLogs with FederatedCredentialId; CloudTrail AssumeRoleWithWebIdentity; Google Cloud audit logs for the impersonated service account).

See also


Related Files


โฌ…๏ธ Cloud Identity index | Master Index | ๐ŸŽฏ Role Navigation | Legal Notice


๐Ÿ“„ Source: Cloud/Identity/conditional-access-and-workload-identities.md | โœ๏ธ Suggest an edit | โฌ…๏ธ Back to Cloud

Clone this wiki locally