Skip to content

Commit 6f7dd70

Browse files
Merge pull request #1119 from bryan-cox/NE-1688
NE-1688: Enable Azure MSI authentication for ARO HCP
2 parents a01ed6c + 1764dd2 commit 6f7dd70

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/dns/azure/client/auth.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,21 @@ func getAuthorizerForResource(config Config) (autorest.Authorizer, error) {
7070
}
7171

7272
var cred azcore.TokenCredential
73-
if config.AzureWorkloadIdentityEnabled && strings.TrimSpace(config.ClientSecret) == "" {
73+
// MSI Override for ARO HCP
74+
msi := os.Getenv("AZURE_MSI_AUTHENTICATION")
75+
if msi == "true" {
76+
options := azidentity.ManagedIdentityCredentialOptions{
77+
ClientOptions: azcore.ClientOptions{
78+
Cloud: cloudConfig,
79+
},
80+
}
81+
82+
var err error
83+
cred, err = azidentity.NewManagedIdentityCredential(&options)
84+
if err != nil {
85+
return nil, err
86+
}
87+
} else if config.AzureWorkloadIdentityEnabled && strings.TrimSpace(config.ClientSecret) == "" {
7488
options := azidentity.WorkloadIdentityCredentialOptions{
7589
ClientOptions: azcore.ClientOptions{
7690
Cloud: cloudConfig,

0 commit comments

Comments
 (0)