Skip to content

fix(github): use API-resolved org login for OIDC subject claims#135

Open
DanielBoring wants to merge 1 commit intoAzure:mainfrom
DanielBoring:fix/oidc-subject-org-name-casing
Open

fix(github): use API-resolved org login for OIDC subject claims#135
DanielBoring wants to merge 1 commit intoAzure:mainfrom
DanielBoring:fix/oidc-subject-org-name-casing

Conversation

@DanielBoring
Copy link
Copy Markdown

@DanielBoring DanielBoring commented Apr 24, 2026

TL;DR

Hi Team!! I found this issue while using Deploy-Accelerator and wanted to submit the fix I found. This PR fixes GitHub OIDC federated credential subject casing mismatches that can cause AADSTS7002138 after Entra case-sensitive matching enforcement.

The module previously built subject claims from raw user input (var.organization_name), which can differ from GitHub’s canonical org login casing.
This change uses data.github_organization.alz.login for the repo: segment and uses lower(data.github_organization.alz.login) for the job_workflow_ref org segment.

Result: future bootstrap deployments generate subject claims that match runtime GitHub token assertions for the org casing scenario you hit.


Detailed Notes

Problem

Entra (Azure AD) now enforces case-sensitive matching on federated credential subjects.
The bootstrap GitHub module generated subject claims using user-entered org name casing, which can differ from GitHub’s canonical org login casing used in OIDC assertions.

Observed failure:
AADSTS7002138: No matching federated identity record found for presented assertion subject

Impact

If org casing in inputs differs from GitHub canonical login casing, GitHub Actions authentication to Azure can fail for plan/apply workflows that rely on workload identity federation.

Root Cause

Subject claims were composed from:

  • var.organization_name (raw user input)

instead of:

  • data.github_organization.alz.login (provider/API-resolved canonical org login)

What Changed

File changed:

  • locals.tf

Code updates:

  1. template_claim_structure now uses:
    lower(data.github_organization.alz.login)
  2. subject (repo: segment) now uses:
    data.github_organization.alz.login

Why This Fix

  • Removes dependency on user-typed casing.
  • Uses GitHub provider data as source of truth.
  • Minimal, targeted change in the only GitHub OIDC subject generation path.

Validation Performed

  1. Confirmed only one active GitHub subject construction path exists.
  2. Confirmed flow from github outputs into Azure federated credential resource.
  3. Confirmed diff scope is only two substitutions in one file.
  4. Branch and commit are isolated to this bug fix.

Risk / Compatibility

  • Low risk: no new resources, no schema changes, only subject string composition source.
  • Backward compatible for already-correct inputs.
  • Fixes incorrect/mixed-case input scenarios.

Operational Note for Existing Deployments

This PR prevents future incorrect subject generation.
Already-deployed credentials with wrong subject values may still require delete + recreate to ensure Entra-side propagation, as documented in incident notes.

Reference

Use data.github_organization.alz.login instead of var.organization_name when constructing OIDC subject claims for federated credentials.

This preserves exact org casing in the repo: segment to match GitHub token assertions and avoid AADSTS7002138 case-sensitive matching failures.

Also lower-case the org in job_workflow_ref template composition to align with observed GitHub token behavior for reusable workflow refs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant