@@ -128,8 +128,8 @@ const (
128
128
podNameField = "csi.storage.k8s.io/pod.name"
129
129
podNamespaceField = "csi.storage.k8s.io/pod.namespace"
130
130
serviceAccountTokenField = "csi.storage.k8s.io/serviceAccount.tokens"
131
- clientIDField = "clientID "
132
- tenantIDField = "tenantID "
131
+ clientIDField = "clientid "
132
+ tenantIDField = "tenantid "
133
133
mountOptionsField = "mountoptions"
134
134
mountPermissionsField = "mountpermissions"
135
135
encryptInTransitField = "encryptintransit"
@@ -777,7 +777,7 @@ func (d *Driver) GetAccountInfo(ctx context.Context, volumeID string, secrets, r
777
777
778
778
var protocol , accountKey , secretName , pvcNamespace string
779
779
// getAccountKeyFromSecret indicates whether get account key only from k8s secret
780
- var getAccountKeyFromSecret , getLatestAccountKey bool
780
+ var getAccountKeyFromSecret , getLatestAccountKey , mountWithManagedIdentity bool
781
781
var clientID , tenantID , serviceAccountToken string
782
782
783
783
for k , v := range reqContext {
@@ -808,8 +808,12 @@ func (d *Driver) GetAccountInfo(ctx context.Context, volumeID string, secrets, r
808
808
if getLatestAccountKey , err = strconv .ParseBool (v ); err != nil {
809
809
return rgName , accountName , accountKey , fileShareName , diskName , subsID , fmt .Errorf ("invalid %s: %s in volume context" , getLatestAccountKeyField , v )
810
810
}
811
- case strings . ToLower ( clientIDField ) :
811
+ case clientIDField :
812
812
clientID = v
813
+ case mountWithManagedIdentityField :
814
+ if mountWithManagedIdentity , err = strconv .ParseBool (v ); err != nil {
815
+ return rgName , accountName , accountKey , fileShareName , diskName , subsID , fmt .Errorf ("invalid %s: %s in volume context" , mountWithManagedIdentityField , v )
816
+ }
813
817
case strings .ToLower (tenantIDField ):
814
818
tenantID = v
815
819
case strings .ToLower (serviceAccountTokenField ):
@@ -839,7 +843,11 @@ func (d *Driver) GetAccountInfo(ctx context.Context, volumeID string, secrets, r
839
843
}
840
844
}
841
845
842
- // if client id is specified, we only use service account token to get account key
846
+ if mountWithManagedIdentity {
847
+ klog .V (2 ).Infof ("mountWithManagedIdentity is true, use managed identity auth" )
848
+ return rgName , accountName , accountKey , fileShareName , diskName , subsID , nil
849
+ }
850
+
843
851
if clientID != "" {
844
852
klog .V (2 ).Infof ("clientID(%s) is specified, use service account token to get account key" , clientID )
845
853
accountKey , err := d .cloud .GetStorageAccesskeyFromServiceAccountToken (ctx , subsID , accountName , rgName , clientID , tenantID , serviceAccountToken )
0 commit comments