Skip to content

Commit 8345f6e

Browse files
committed
fix(github): use API-resolved org login for OIDC subject claims
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.
1 parent a8d968f commit 8345f6e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

modules/github/locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ locals {
1818

1919
locals {
2020
repository_name_templates = var.use_template_repository ? var.repository_name_templates : var.repository_name
21-
template_claim_structure = "${var.organization_name}/${local.repository_name_templates}/%s@refs/heads/main"
21+
template_claim_structure = "${lower(data.github_organization.alz.login)}/${local.repository_name_templates}/%s@refs/heads/main"
2222

2323
oidc_subjects_flattened = flatten([for key, value in var.workflows : [
2424
for environment_user_assigned_managed_identity_mapping in value.environment_user_assigned_managed_identity_mappings :
2525
{
2626
subject_key = "${key}-${environment_user_assigned_managed_identity_mapping.user_assigned_managed_identity_key}"
2727
user_assigned_managed_identity_key = environment_user_assigned_managed_identity_mapping.user_assigned_managed_identity_key
28-
subject = "repo:${var.organization_name}/${var.repository_name}:environment:${var.environments[environment_user_assigned_managed_identity_mapping.environment_key]}:job_workflow_ref:${format(local.template_claim_structure, value.workflow_file_name)}"
28+
subject = "repo:${data.github_organization.alz.login}/${var.repository_name}:environment:${var.environments[environment_user_assigned_managed_identity_mapping.environment_key]}:job_workflow_ref:${format(local.template_claim_structure, value.workflow_file_name)}"
2929
}
3030
]
3131
])

0 commit comments

Comments
 (0)