@@ -27,6 +27,7 @@ import (
27
27
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
28
28
azureautorest "github.com/Azure/go-autorest/autorest/azure"
29
29
"github.com/Azure/go-autorest/autorest/azure/auth"
30
+ infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
30
31
)
31
32
32
33
// AzureClients contains all the Azure clients used by the scopes.
@@ -36,6 +37,8 @@ type AzureClients struct {
36
37
TokenCredential azcore.TokenCredential
37
38
ResourceManagerEndpoint string
38
39
ResourceManagerVMDNSSuffix string
40
+
41
+ authType infrav1.IdentityType
39
42
}
40
43
41
44
// CloudEnvironment returns the Azure environment the controller runs in.
@@ -73,7 +76,7 @@ func (c *AzureClients) Token() azcore.TokenCredential {
73
76
// ClientID).
74
77
func (c * AzureClients ) HashKey () string {
75
78
hasher := sha256 .New ()
76
- _ , _ = hasher .Write ([]byte (c .TenantID () + c .CloudEnvironment () + c .SubscriptionID () + c .ClientID ()))
79
+ _ , _ = hasher .Write ([]byte (c .TenantID () + c .CloudEnvironment () + c .SubscriptionID () + c .ClientID () + string ( c . authType ) ))
77
80
return base64 .URLEncoding .EncodeToString (hasher .Sum (nil ))
78
81
}
79
82
@@ -107,6 +110,8 @@ func (c *AzureClients) setCredentialsWithProvider(ctx context.Context, subscript
107
110
}
108
111
c .Values ["AZURE_CLIENT_SECRET" ] = strings .TrimSuffix (clientSecret , "\n " )
109
112
113
+ c .authType = credentialsProvider .Type ()
114
+
110
115
tokenCredential , err := credentialsProvider .GetTokenCredential (ctx , c .ResourceManagerEndpoint , c .Environment .ActiveDirectoryEndpoint , c .Environment .TokenAudience )
111
116
if err != nil {
112
117
return err
0 commit comments