@@ -51,6 +51,11 @@ const (
5151 clientCertificateField = "clientCertificate"
5252 clientCertificatePasswordField = "clientCertificatePassword"
5353 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"
5459)
5560
5661// BlobClient is a minimal Azure Blob client for fetching objects.
@@ -65,6 +70,9 @@ type BlobClient struct {
6570//
6671// - azidentity.ClientSecretCredential when `tenantId`, `clientId` and
6772// `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
6876// - azidentity.ClientCertificateCredential when `tenantId`,
6977// `clientCertificate` (and optionally `clientCertificatePassword`) fields
7078// are found.
@@ -130,6 +138,13 @@ func ValidateSecret(secret *corev1.Secret) error {
130138 }
131139 }
132140 }
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+ }
133148 if _ , hasResourceID := secret .Data [resourceIDField ]; hasResourceID {
134149 valid = true
135150 }
@@ -284,6 +299,13 @@ func tokenCredentialFromSecret(secret *corev1.Secret) (azcore.TokenCredential, e
284299 return azidentity .NewClientCertificateCredential (string (tenantID ), string (clientID ), certs , key , nil )
285300 }
286301 }
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+ }
287309 if hasClientID {
288310 return azidentity .NewManagedIdentityCredential (& azidentity.ManagedIdentityCredentialOptions {
289311 ID : azidentity .ClientID (clientID ),
0 commit comments