Skip to content

feat: support use_immutable_subject and sub_claim_prefix on repository OIDC subject claim template - #3582

Open
madriaanse377 wants to merge 1 commit into
integrations:mainfrom
madriaanse377:feat/oidc-immutable-subject-claims
Open

feat: support use_immutable_subject and sub_claim_prefix on repository OIDC subject claim template#3582
madriaanse377 wants to merge 1 commit into
integrations:mainfrom
madriaanse377:feat/oidc-immutable-subject-claims

Conversation

@madriaanse377

Copy link
Copy Markdown

Summary

Wires use_immutable_subject and sub_claim_prefix — already present on go-github v89's OIDCSubjectClaimCustomTemplate struct — through to github_actions_repository_oidc_subject_claim_customization_template.

This lets a repository created before GitHub's July 15, 2026 immutable-subject-claims rollout opt in individually via Terraform, instead of requiring an org-wide toggle or an out-of-band REST call that Terraform can't track.

Changes

  • use_immutable_subject (bool, optional, computed) and sub_claim_prefix (string, optional, computed) added to the resource schema
  • Both fields wired into CreateOrUpdate and Read, following the existing GetOk + new(...) pattern already used elsewhere in this resource (include_claim_keys) and in sibling resources (e.g. resource_github_enterprise_actions_workflow_permissions.go)
  • Docs (docs/resources/...md and its .tmpl source) and the example under examples/resources/... updated to cover both new arguments
  • New acceptance test subtest asserting both fields round-trip correctly

Scoped to the repository-level resource only, matching the issue — the organization-level resource and this resource's Delete behavior are unchanged.

Closes #3548

Test plan

  • Maintainer-run acceptance suite (TestAccGithubActionsRepositoryOIDCSubjectClaimCustomizationTemplate), since these require a live GitHub token this environment doesn't have
  • Manual diff review against the existing use_default/include_claim_keys and can_approve_pull_request_reviews patterns for consistency

…y OIDC subject claim template

Wires the use_immutable_subject and sub_claim_prefix fields (already present
on go-github v89's OIDCSubjectClaimCustomTemplate struct) through the
github_actions_repository_oidc_subject_claim_customization_template resource,
allowing existing repositories to opt into GitHub's immutable OIDC subject
claim format on a per-repository basis without an org-wide change.

Closes integrations#3548
@github-actions github-actions Bot added the Type: Feature New feature or request label Jul 28, 2026
@github-actions

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@deiga deiga added the r/repo_oidc_subject_claim_customization_tmpl actions_repository_oidc_subject_claim_customization_template label Jul 28, 2026
@RulerOf

RulerOf commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Just an FYI, I got bit by this today trying to resolve an issue with a new microservice's OIDC config. The API publishes use_immutable_subject but that value seems to lie.

In this older repo, the UI and API agree:

Google Chrome 2026-08-04 at 17 03 53
╰─❯ gh api /repos/BuyerQuest/redacted-old-repo/actions/oidc/customization/sub
{
  "use_default": true,
  "use_immutable_subject": false,
  "sub_claim_prefix": "repo:BuyerQuest/redacted-old-repo"
}

But this newer repo created after the compulsive switchover they disagree entirely:

Google Chrome 2026-08-04 at 16 57 22
gh api /repos/BuyerQuest/redacted-new-repo/actions/oidc/customization/sub
{
  "use_default": true,
  "use_immutable_subject": false,
  "sub_claim_prefix": "repo:BuyerQuest@123445689/redacted-new-repo@987654321"
}

I bring this up because what I wanted to do was inspect the true/false of use_immutable_subject from the data source to construct the sub, but it doesn't appear to be reliable via the API.

I'm using this as a workaround:

data "github_repository" "this" {
  full_name = "${local.github_org}/${var.github_repository}"
}

data "github_rest_api" "repo_oidc" {
  endpoint = "repos/${data.github_repository.this.full_name}/actions/oidc/customization/sub"
}

module "github_actions_role" {
  source  = "philips-labs/github-oidc/aws"
  version = "0.8.1"

  openid_connect_provider_arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/token.actions.githubusercontent.com"
  repo                        = data.github_repository.this.full_name
  role_name                   = "${local.name_prefix}-deploy"
  role_path                   = "/github-actions/"

  default_conditions = [
    "deny_pull_request",
  ]

  // GitHub reports the exact prefix it uses for this repository. This handles both the
  // name-based and immutable name@id formats without duplicating GitHub's selection logic.
  conditions = [
    {
      test     = "StringEquals"
      variable = "token.actions.githubusercontent.com:sub"
      values = [
        "${jsondecode(data.github_rest_api.repo_oidc.body).sub_claim_prefix}:environment:${github_repository_environment.this.environment}",
      ]
    },
  ]

Unless I'm mistaken, for the data source it may be worth computing it based on the qualities of sub_claim_prefix (e.g. an @ symbol in it anywhere means it should be true), or possibly disabling it until github fixes whatever the problem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

r/repo_oidc_subject_claim_customization_tmpl actions_repository_oidc_subject_claim_customization_template Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support use_immutable_subject on github_actions_repository_oidc_subject_claim_customization_template

3 participants