@@ -120,9 +120,9 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
120120 }
121121 var sku , subsID , resourceGroup , location , account , fileShareName , diskName , fsType , secretName string
122122 var secretNamespace , pvcNamespace , protocol , customTags , storageEndpointSuffix , networkEndpointType , shareAccessTier , accountAccessTier , rootSquashType , tagValueDelimiter string
123- var createAccount , useSeretCache , matchTags , selectRandomMatchingAccount , getLatestAccountKey , encryptInTransit bool
123+ var createAccount , useSeretCache , matchTags , selectRandomMatchingAccount , getLatestAccountKey , encryptInTransit , mountWithManagedIdentity , mountWithWIToken bool
124124 var vnetResourceGroup , vnetName , vnetLinkName , publicNetworkAccess , subnetName , shareNamePrefix , fsGroupChangePolicy , useDataPlaneAPI string
125- var requireInfraEncryption , disableDeleteRetentionPolicy , enableLFS , isMultichannelEnabled , allowSharedKeyAccess , requiresSmbOAuth * bool
125+ var requireInfraEncryption , disableDeleteRetentionPolicy , enableLFS , isMultichannelEnabled , allowSharedKeyAccess * bool
126126 var provisionedBandwidthMibps , provisionedIops * int32
127127 // set allowBlobPublicAccess as false by default
128128 allowBlobPublicAccess := ptr .To (false )
@@ -131,6 +131,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
131131 // store account key to k8s secret by default
132132 storeAccountKey := true
133133
134+ var err error
134135 var accountQuota int32
135136 // Apply ProvisionerParameters (case-insensitive). We leave validation of
136137 // the values to the cloud provider.
@@ -298,26 +299,24 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
298299 }
299300 provisionedIops = to .Ptr (int32 (value ))
300301 case mountWithManagedIdentityField :
301- value , err : = strconv .ParseBool (v )
302+ mountWithManagedIdentity , err = strconv .ParseBool (v )
302303 if err != nil {
303304 return nil , status .Errorf (codes .InvalidArgument , "invalid %s: %s in storage class" , mountWithManagedIdentityField , v )
304305 }
305- if value {
306- requiresSmbOAuth = & value
307- }
308306 case mountWithWITokenField :
309- value , err : = strconv .ParseBool (v )
307+ mountWithWIToken , err = strconv .ParseBool (v )
310308 if err != nil {
311309 return nil , status .Errorf (codes .InvalidArgument , "invalid %s: %s in storage class" , mountWithWITokenField , v )
312310 }
313- if value {
314- requiresSmbOAuth = & value
315- }
316311 default :
317312 return nil , status .Errorf (codes .InvalidArgument , "invalid parameter %q in storage class" , k )
318313 }
319314 }
320315
316+ if mountWithManagedIdentity && mountWithWIToken {
317+ return nil , status .Error (codes .InvalidArgument , "mountwithmanagedidentity and mountwithworkloadidentitytoken cannot be both true in storage class" )
318+ }
319+
321320 if matchTags && account != "" {
322321 return nil , status .Errorf (codes .InvalidArgument , "matchTags must set as false when storageAccount(%s) is provided" , account )
323322 }
@@ -535,6 +534,12 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
535534 }
536535 }
537536
537+ var requiresSmbOAuth * bool
538+ if mountWithManagedIdentity || mountWithWIToken {
539+ klog .V (2 ).Info ("enabling smb oauth for managed identity or work identity token based mount" )
540+ requiresSmbOAuth = to .Ptr (true )
541+ }
542+
538543 accountOptions := & storage.AccountOptions {
539544 Name : account ,
540545 Type : sku ,
0 commit comments