Skip to content

Commit 1346696

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 <[email protected]>
1 parent 26f00da commit 1346696

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/azure/blob.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ func sharedCredentialFromSecret(endpoint string, secret *corev1.Secret) (*azblob
358358
// azidentity.ChainedTokenCredential if at least one of the following tokens was
359359
// successfully created:
360360
// - azidentity.EnvironmentCredential
361+
// - azidentity.ManagedIdentityCredential with Client ID from AZURE_CLIENT_ID
362+
// environment variable, if found.
361363
// - azidentity.ManagedIdentityCredential
362364
// If a Secret with an `authorityHost` is provided, this is set on the
363365
// azidentity.EnvironmentCredentialOptions. It may return nil.
@@ -374,6 +376,13 @@ func chainCredentialWithSecret(secret *corev1.Secret) (azcore.TokenCredential, e
374376
if token, _ := azidentity.NewEnvironmentCredential(credOpts); token != nil {
375377
creds = append(creds, token)
376378
}
379+
if clientID := os.Getenv("AZURE_CLIENT_ID"); clientID != "" {
380+
if token, _ := azidentity.NewManagedIdentityCredential(&azidentity.ManagedIdentityCredentialOptions{
381+
ID: azidentity.ClientID(clientID),
382+
}); token != nil {
383+
creds = append(creds, token)
384+
}
385+
}
377386
if token, _ := azidentity.NewManagedIdentityCredential(nil); token != nil {
378387
creds = append(creds, token)
379388
}

0 commit comments

Comments
 (0)