Repository navigation
feat: try identity binding before workload identity for Azure Key Vault - #3144
Merged
Merged
Conversation
When the pod has identity binding configured, the Azure Key Vault key provider now tries the identity binding credential first and falls back to the existing workload identity and managed identity chain if it fails. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Xinhe Li <xinhl@microsoft.com>
fseldow
requested review from
akashsinghal,
binbin-li,
jimmyraywv,
luisdlp,
susanshi and
toddysm
as code owners
November 26, 2026 08:29
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3144 +/- ##
==========================================
- Coverage 86.76% 86.71% -0.05%
==========================================
Files 56 56
Lines 2977 3012 +35
==========================================
+ Hits 2583 2612 +29
- Misses 301 305 +4
- Partials 93 95 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
An unbounded Azure token-proxy request can hang provider initialization indefinitely, preventing fallback to working workload or managed identity credentials.
1 open issue
What changed in this PR
This PR adds identity-binding authentication to the Azure Key Vault key provider, preferring it over the existing workload identity and managed identity chain. ACR authentication remains unchanged.
Changes:
- Load identity-binding configuration when initializing the Key Vault provider.
- Fall back to the existing credential chain when identity binding is unavailable or token acquisition fails.
- Add unit tests for credential selection, fallback behavior, and combined errors.
| File | Description |
|---|---|
internal/verifier/keyprovider/azurekeyvault/register.go |
Load identity-binding configuration and use the new credential chain. |
internal/cloudprovider/azure/tokencredential.go |
Add identity-binding-first credential construction and token fallback. |
internal/cloudprovider/azure/tokencredential_test.go |
Test credential selection and token fallback outcomes. |
Review effort: Balanced
…allback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Xinhe Li <xinhl@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
The Azure Key Vault key provider used only the workload identity → managed identity chain. On clusters that use Kubernetes identity binding, it could not get a token through identity binding.
This PR makes the AKV provider try identity binding first, then fall back to the existing chain:
AZURE_KUBERNETES_SNI_NAME/AZURE_ACR_IDENTITY_BINDING_SNI_NAME, etc., read byLoadIdentityBindingConfigFromEnv).Changes
internal/cloudprovider/azure/tokencredential.go: addCreateCredentialChainPreferIdentityBindingand afallbackCredential.azidentity.ChainedTokenCredentialonly moves to the next source when it gets acredentialUnavailableError, which a custom credential can't return. So the new credential falls back to the workload identity / managed identity chain on any identity binding error. If both fail, the returned error includes both errors.internal/verifier/keyprovider/azurekeyvault/register.go: use the new chain.Type of change
How Has This Been Tested?
fallbackCredential(primary succeeds, falls back, both fail) and forCreateCredentialChainPreferIdentityBinding(no config, no SNI, can't build the IB credential, IB first).go test ./internal/cloudprovider/azure/... ./internal/verifier/keyprovider/azurekeyvault/...andgo vetpass.Checklist