Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/azidentity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### Bugs Fixed

### Other Changes
- `DefaultAzureCredential` tries its next credential when a dev tool credential such as
`AzureCLICredential` returns an error

## 1.11.0-beta.1 (2025-07-15)

Expand Down
7 changes: 6 additions & 1 deletion sdk/azidentity/default_azure_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ func NewDefaultAzureCredential(options *DefaultAzureCredentialOptions) (*Default
}
}
if selected&az != 0 {
azCred, err := NewAzureCLICredential(&AzureCLICredentialOptions{AdditionallyAllowedTenants: additionalTenants, TenantID: options.TenantID})
azCred, err := NewAzureCLICredential(&AzureCLICredentialOptions{
AdditionallyAllowedTenants: additionalTenants,
TenantID: options.TenantID,
inDefaultChain: true,
})
if err == nil {
creds = append(creds, azCred)
} else {
Expand All @@ -178,6 +182,7 @@ func NewDefaultAzureCredential(options *DefaultAzureCredentialOptions) (*Default
azdCred, err := NewAzureDeveloperCLICredential(&AzureDeveloperCLICredentialOptions{
AdditionallyAllowedTenants: additionalTenants,
TenantID: options.TenantID,
inDefaultChain: true,
})
if err == nil {
creds = append(creds, azdCred)
Expand Down
22 changes: 22 additions & 0 deletions sdk/azidentity/default_azure_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ func TestDefaultAzureCredential_AZURE_TOKEN_CREDENTIALS(t *testing.T) {
})
}

func TestDefaultAzureCredential_CLICredentialOptions(t *testing.T) {
require := require.New(t)
cred, err := NewDefaultAzureCredential(nil)
require.NoError(err)
var (
az *AzureCLICredential
azd *AzureDeveloperCLICredential
)
for _, s := range cred.chain.sources {
if az == nil {
az, _ = s.(*AzureCLICredential)
}
if azd == nil {
azd, _ = s.(*AzureDeveloperCLICredential)
}
}
require.NotNil(az, "%T should be in the default chain", az)
require.True(az.opts.inDefaultChain)
require.NotNil(azd, "%T should be in the default chain", azd)
Comment thread
chlowell marked this conversation as resolved.
Comment thread
chlowell marked this conversation as resolved.
require.True(azd.opts.inDefaultChain)
}

func TestDefaultAzureCredential_ConstructorErrors(t *testing.T) {
// ensure NewEnvironmentCredential returns an error
t.Setenv(azureTenantID, "")
Expand Down