Skip to content

[Identity] Add GitHubActionsCredential - #50916

Open
vcolin7 wants to merge 16 commits into
Azure:mainfrom
vcolin7:vcolin7-github-actions-credential
Open

vcolin7 wants to merge 16 commits into
Azure:mainfrom
vcolin7:vcolin7-github-actions-credential

Conversation

@vcolin7

@vcolin7 vcolin7 commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Description

Adds GitHubActionsCredential and GitHubActionsCredentialBuilder to both Java Identity packages so GitHub Actions workflows can authenticate through OIDC federation without a client secret or certificate.

Fixes #50642.

  • Reads the GitHub runner's OIDC configuration, derives the assertion audience for the six supported clouds, and uses the existing confidential-client authentication and token-cache paths.
  • Supports explicit tenant/client ID overrides with environment fallbacks and build-time validation. Keeps DefaultAzureCredential unchanged.
  • Adds deterministic tests, compiled snippets, JavaDoc, README/troubleshooting guidance, and changelog entries. Includes an opt-in live workflow with a test-branch push trigger and manual dispatch.

Adapts the reference implementation in Azure/azure-sdk-for-js#38581 to each Java package's existing builder and token APIs. No Swagger or TypeSpec regeneration is involved.

Validation

Live E2E passed on this PR head: workflow run. Both packages were built from source and executed:

mvn -B -ntp -f "$SDK_POM" test -Dtest=GitHubActionsCredentialLiveTest

Each package reported one live test, zero failures, zero errors, and zero skips. This exercised real GitHub OIDC and Entra token acquisition, including both token APIs in the existing Identity package and the synchronous v2 API. Workflow lint also passed.

The otherwise successful build logged an existing Revapi scanner error for WindowsCredentialApi.CREDENTIAL_ATTRIBUTE.ByReference, so its API-analysis result is inconclusive. Full repository test suites were not run. The branch retains its existing main synchronization merge commits.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Written with the help or Copilot

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
34 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The cross-package authentication addition needs human review, with unresolved async correctness issues and inconclusive API compatibility analysis.

2 open issues
What changed in this PR

Adds standalone GitHubActionsCredential support to both Java Identity packages, enabling secretless authentication through GitHub Actions OIDC federation without changing DefaultAzureCredential.

Changes:

  • Adds credential builders, environment configuration, and audience mappings for six supported clouds.
  • Reuses existing authentication and token-cache infrastructure, with deterministic tests and an opt-in live workflow.
  • Adds compiled examples, setup and troubleshooting documentation, and release notes.
File Description
sdk/​identity/​azure-identity/​TROUBLESHOOTING.md Documents configuration and authentication failures.
sdk/​identity/​azure-identity/​src/​test/​java/​com/​azure/​identity/​GitHubActionsCredentialTest.java Tests token exchange, caching, failures, and request options.
sdk/​identity/​azure-identity/​src/​test/​java/​com/​azure/​identity/​GitHubActionsCredentialLiveTest.java Adds opt-in synchronous and asynchronous live checks.
sdk/​identity/​azure-identity/​src/​test/​java/​com/​azure/​identity/​GitHubActionsCredentialBuilderTest.java Tests configuration precedence, validation, and audiences.
sdk/​identity/​azure-identity/​src/​samples/​java/​com/​azure/​identity/​credential/​JavaDocCodeSnippets.java Adds compiled credential construction examples.
sdk/​identity/​azure-identity/​src/​main/​java/​com/​azure/​identity/​GitHubActionsCredentialBuilder.java Resolves and validates credential configuration.
sdk/​identity/​azure-identity/​src/​main/​java/​com/​azure/​identity/​GitHubActionsCredential.java Implements OIDC assertion retrieval and token acquisition.
sdk/​identity/​azure-identity/​README.md Explains federation setup, cloud audiences, and live testing.
sdk/​identity/​azure-identity/​CHANGELOG.md Records the new credential feature.
sdk/​identity-v2/​azure-identity/​src/​test/​java/​com/​azure/​v2/​identity/​GitHubActionsCredentialTest.java Tests v2 token exchange, caching, and failures.
sdk/​identity-v2/​azure-identity/​src/​test/​java/​com/​azure/​v2/​identity/​GitHubActionsCredentialLiveTest.java Adds an opt-in v2 live authentication check.
sdk/​identity-v2/​azure-identity/​src/​test/​java/​com/​azure/​v2/​identity/​GitHubActionsCredentialJavaDocCodeSnippets.java Provides compiled v2 documentation examples.
sdk/​identity-v2/​azure-identity/​src/​test/​java/​com/​azure/​v2/​identity/​GitHubActionsCredentialBuilderTest.java Tests v2 configuration and audience selection.
sdk/​identity-v2/​azure-identity/​src/​main/​java/​com/​azure/​v2/​identity/​GitHubActionsCredentialBuilder.java Adds v2 configuration resolution and validation.
sdk/​identity-v2/​azure-identity/​src/​main/​java/​com/​azure/​v2/​identity/​GitHubActionsCredential.java Implements synchronous v2 federated authentication.
sdk/​identity-v2/​azure-identity/​README.md Documents v2 setup, usage, and troubleshooting.
sdk/​identity-v2/​azure-identity/​pom.xml Configures snippet discovery in test sources.
sdk/​identity-v2/​azure-identity/​CHANGELOG.md Records the v2 credential feature.
.github/​workflows/​identity-github-actions-credential.yml Builds both packages and runs opt-in live authentication tests.

Review effort: Balanced

@vcolin7
vcolin7 force-pushed the vcolin7-github-actions-credential branch from f6ac393 to b05b5df Compare October 22, 2026 11:15
env:
AZURE_TENANT_ID: ${{ vars.AZURE_IDENTITY_GITHUB_ACTIONS_TENANT_ID }}
AZURE_CLIENT_ID: ${{ vars.AZURE_IDENTITY_GITHUB_ACTIONS_CLIENT_ID }}
AZURE_AUTHORITY_HOST: https://login.microsoftonline.com/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value is there by default for the authority host. We don't need to mention it.

}
}

private static String readAssertion(Response<BinaryData> response) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering that we could have error message compatibility across languages on this. https://github.com/Azure/azure-sdk-for-js/pull/38581/changes#diff-3b6a7dcba9e90d666bcd7e019746284e95303c04dbdacbc7c70fc82b924c33e5R20 These are some that are covered by JS. Maybe for cases like null or failed to pass OIDC response we can align. It just makes debugging cross language easier in case of customer reports. But this looks thorough to me.

This branch has not been deployed

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

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

[Identity] Add GithubActionsCredential to azure identity sdk

4 participants