Skip to content

implement identity bindings - #5083

Open
Mitch Connors (therealmitchconnors) wants to merge 4 commits into
Azure:mainfrom
therealmitchconnors:identity-binding
Open

implement identity bindings #5083
Mitch Connors (therealmitchconnors) wants to merge 4 commits into
Azure:mainfrom
therealmitchconnors:identity-binding

Conversation

@therealmitchconnors

Copy link
Copy Markdown

Fixes #3456

Adds a custom token proxy implementing identity binding.

See attached issue and links for design, compare to implementation in go client.

@azure-pipelines

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

@github-actions github-actions Bot added Azure.Identity The azure_identity crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Aug 18, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your contribution Mitch Connors (@therealmitchconnors)! We will review the pull request and get back to you soon.

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.

Pull request overview

Adds opt-in AKS workload identity binding support to WorkloadIdentityCredential.

Changes:

  • Adds a custom token-proxy transport with CA and SNI support.
  • Adds proxy configuration, tests, troubleshooting guidance, and feature dependencies.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/identity/azure_identity/TROUBLESHOOTING.md Documents proxy configuration failures.
sdk/identity/azure_identity/src/workload_identity_credential.rs Integrates opt-in proxy support and tests.
sdk/identity/azure_identity/src/lib.rs Registers the proxy module.
sdk/identity/azure_identity/src/custom_token_proxy.rs Implements proxy validation, TLS, URL rewriting, and CA rotation.
sdk/identity/azure_identity/Cargo.toml Adds the proxy feature and reqwest dependency.
Cargo.lock Records the dependency update.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdk/identity/azure_identity/src/custom_token_proxy.rs Outdated
Comment thread sdk/identity/azure_identity/src/workload_identity_credential.rs Outdated
Comment thread sdk/identity/azure_identity/src/workload_identity_credential.rs
Comment thread sdk/identity/azure_identity/src/custom_token_proxy.rs Outdated

@heaths Heath Stewart (heaths) left a comment

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.

Please update the PR title to be more descriptive as well.

Comment thread .vscode/cspell.json
"aarch",
"accountendpoint",
"accountkey",
"addrs",

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.

Service directory "misspellings" should go into sdk/identity/.cspell.json. There are agent instructions that help do this e.g., the /check-spelling skill.

[features]
default = ["azure_core/default"]
default = ["azure_core/default", "azure_proxy"]
azure_proxy = ["dep:reqwest", "azure_core/reqwest_rustls"]

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.

  1. Can you describe this more?
  2. No need to repeat "azure". It's a feature in an azure_* crate already. No other crate does that.

### Features Added

- Added support for Arc-connected servers when using the `ManagedIdentityCredential`.
- Added opt-in AKS identity binding support to `WorkloadIdentityCredentialOptions` through `enable_azure_proxy`.

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 recommend spelling out "AKS" in any documentation at least the first time it's used. Better for SEO and for people who may not be as familiar with it.

/// requests tokens directly from Microsoft Entra ID. See the
/// [AKS identity bindings documentation](https://learn.microsoft.com/azure/aks/identity-bindings-concepts)
/// for guidance about enabling this option.
pub enable_azure_proxy: bool,

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.

Is the word "azure" here really needed? This is all "azure". If it really is a product name called "Azure Proxy" fine, but seems redundant.

// Licensed under the MIT License.

use crate::env::Env;
#[cfg(feature = "azure_proxy")]

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.

Is this module even needed if the feature isn't enabled? Probably easier just to conditionally include it from lib.rs if enabled, and have fewer cfg conditions in workload_identity_credential.rs.

let ca_file = optional_env(env, AZURE_KUBERNETES_CA_FILE);
let ca_data = optional_env(env, AZURE_KUBERNETES_CA_DATA);

if proxy.is_none() {

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.

Use:

let Some(proxy) = proxy else {
  // ...
}

Then you don't need the proxy.expect further down. While correct, this is still a code smell and initially raises red flags. Generally, unwrap() or expect() should not be in production code if they can be avoided otherwise.

)
}

fn optional_env(env: &Env, name: &str) -> Option<String> {

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'd add #[inline(always)] here or even make this a macro.

env.var(name).ok().filter(|value| !value.is_empty())
}

fn invalid_configuration(name: &'static str, message: impl Into<String>) -> Error {

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.

Same here for #[inline(always)] or macro.

Comment on lines +283 to +286
let mut builder = reqwest::Client::builder()
.tls_backend_rustls()
.https_only(true)
.redirect(reqwest::redirect::Policy::none());

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 is going to be a problem for 1P who won't use reqwest. Probably need to instead define a pub trait that reqwest::Client can implement when the reqwest feature is enabled for azure_identity—need to define features similar to how we do for azure_core—but so can other HTTP stacks, which means you also need to expose the transport like how we do for azure_core::http::ClientOptions.

fn read_ca_file(path: &std::path::Path) -> azure_core::Result<Vec<u8>> {
let data = fs::read(path).with_context_fn(ErrorKind::Credential, || {
format!(
"failed to read {AZURE_KUBERNETES_CA_FILE} {}",

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.

Suggested change
"failed to read {AZURE_KUBERNETES_CA_FILE} {}",
"failed to read {AZURE_KUBERNETES_CA_FILE}: {}",

@github-project-automation github-project-automation Bot moved this from Untriaged to In Progress in Azure Identity SDK Improvements Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Identity The azure_identity crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Support AKS workload identity binding

4 participants