@@ -51,6 +51,11 @@ const (
51
51
clientCertificateField = "clientCertificate"
52
52
clientCertificatePasswordField = "clientCertificatePassword"
53
53
accountKeyField = "accountKey"
54
+
55
+ // Ref: https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli#manually-create-a-service-principal
56
+ tenantField = "tenant"
57
+ appIDField = "appId"
58
+ passwordField = "password"
54
59
)
55
60
56
61
// BlobClient is a minimal Azure Blob client for fetching objects.
@@ -65,6 +70,9 @@ type BlobClient struct {
65
70
//
66
71
// - azidentity.ClientSecretCredential when `tenantId`, `clientId` and
67
72
// `clientSecret` fields are found.
73
+ // - azidentity.ClientSecretCredential when `tenant`, `appId` and `password`
74
+ // fields are found. To match with the JSON from:
75
+ // https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli#manually-create-a-service-principal
68
76
// - azidentity.ClientCertificateCredential when `tenantId`,
69
77
// `clientCertificate` (and optionally `clientCertificatePassword`) fields
70
78
// are found.
@@ -130,6 +138,13 @@ func ValidateSecret(secret *corev1.Secret) error {
130
138
}
131
139
}
132
140
}
141
+ if _ , hasTenant := secret .Data [tenantField ]; hasTenant {
142
+ if _ , hasAppID := secret .Data [appIDField ]; hasAppID {
143
+ if _ , hasPassword := secret .Data [passwordField ]; hasPassword {
144
+ valid = true
145
+ }
146
+ }
147
+ }
133
148
if _ , hasResourceID := secret .Data [resourceIDField ]; hasResourceID {
134
149
valid = true
135
150
}
@@ -284,6 +299,13 @@ func tokenCredentialFromSecret(secret *corev1.Secret) (azcore.TokenCredential, e
284
299
return azidentity .NewClientCertificateCredential (string (tenantID ), string (clientID ), certs , key , nil )
285
300
}
286
301
}
302
+ if tenant , hasTenant := secret .Data [tenantField ]; hasTenant {
303
+ if appId , hasAppID := secret .Data [appIDField ]; hasAppID {
304
+ if password , hasPassword := secret .Data [passwordField ]; hasPassword {
305
+ return azidentity .NewClientSecretCredential (string (tenant ), string (appId ), string (password ), nil )
306
+ }
307
+ }
308
+ }
287
309
if hasClientID {
288
310
return azidentity .NewManagedIdentityCredential (& azidentity.ManagedIdentityCredentialOptions {
289
311
ID : azidentity .ClientID (clientID ),
0 commit comments