Skip to content

ManagedIdentityCredential constructed differently via different code paths #26959

Description

@theunrepentantgeek

Bug Report

Package Version
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1

If you call NewDefaultAzureCredential() the chain that's returned includes a ManagedIdentityCredential that's configured to "play-nicely" with other credentials: It does an up-front probe for IMDS availability to avoid triggering timeouts and other problems when authenticating.

We discovered this when our command-line app asoctl failed to authenticate, encountering timeouts and io/errors due to MI unavailability on the command line.

If you instead construct the token chain yourself (following recommended practices to take control over how your application can authenticate), this behaviour can't be replicated because the required flag is private.

In the azure-service-operator project we worked around this by detecting IMDS ourselves but it would be better if we didn't need to do this.

The internal flag is set in default_azure_credential.go:

		o := &ManagedIdentityCredentialOptions{
			ClientOptions: options.ClientOptions,
			// enable special DefaultAzureCredential behavior (IMDS probing) only when the chain contains another credential
			dac: selected^managedIdentity != 0,
		}

Expectation: We should be able to construct our own chained-credential that behaves precisely how the default one works.

This could be done by

  • Allowing us to set the dac field ourselves; or
  • Having NewChainedTokenCredential() set the internal flag if/when the chain includes a ManagedIdentityCredential

The later option would be both backward-compatible and a fix for anyone inadvertently encountering errors at the moment.

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

Status
Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions