Skip to content

Commit 166e185

Browse files
committed
Add ManagedIdentity with AZURE_CLIENT_ID
This ensures the Managed Identity authentication works with multiple identities assigned to a single node. Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent cfa4c81 commit 166e185

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/azure/blob.go

+9
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ func sharedCredentialFromSecret(endpoint string, secret *corev1.Secret) (*azblob
353353
// azidentity.ChainedTokenCredential if at least one of the following tokens was
354354
// successfully created:
355355
// - azidentity.EnvironmentCredential
356+
// - azidentity.ManagedIdentityCredential with Client ID from AZURE_CLIENT_ID
357+
// environment variable, if found.
356358
// - azidentity.ManagedIdentityCredential
357359
// If a Secret with an `authorityHost` is provided, this is set on the
358360
// azidentity.EnvironmentCredentialOptions. It may return nil.
@@ -369,6 +371,13 @@ func chainCredentialWithSecret(secret *corev1.Secret) (azcore.TokenCredential, e
369371
if token, _ := azidentity.NewEnvironmentCredential(credOpts); token != nil {
370372
creds = append(creds, token)
371373
}
374+
if clientID := os.Getenv("AZURE_CLIENT_ID"); clientID != "" {
375+
if token, _ := azidentity.NewManagedIdentityCredential(&azidentity.ManagedIdentityCredentialOptions{
376+
ID: azidentity.ClientID(clientID),
377+
}); token != nil {
378+
creds = append(creds, token)
379+
}
380+
}
372381
if token, _ := azidentity.NewManagedIdentityCredential(nil); token != nil {
373382
creds = append(creds, token)
374383
}

0 commit comments

Comments
 (0)