diff --git a/docs/driver-parameters.md b/docs/driver-parameters.md index da5eded63..3dd05c0a1 100644 --- a/docs/driver-parameters.md +++ b/docs/driver-parameters.md @@ -46,6 +46,7 @@ containerNamePrefix | specify Azure storage directory prefix created by driver | server | specify Azure storage account server address | existing server address, e.g. `accountname.privatelink.blob.core.windows.net` | No | if empty, driver will use default `accountname.blob.core.windows.net` or other sovereign cloud account address accessTier | [Access tier for storage account](https://learn.microsoft.com/en-us/azure/storage/blobs/access-tiers-overview) | Standard account can choose `Hot` or `Cool`, and Premium account can only choose `Premium` | No | empty(use default setting for different storage account types) allowBlobPublicAccess | Allow or disallow public access to all blobs or containers for storage account created by driver | `true`,`false` | No | `false` +allowSharedKeyAccess | Allow or disallow shared key access for storage account created by driver | `true`,`false` | No | `true` requireInfraEncryption | specify whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest for storage account created by driver | `true`,`false` | No | `false` storageEndpointSuffix | specify Azure storage endpoint suffix | `core.windows.net`, `core.chinacloudapi.cn`, etc | No | if empty, driver will use default storage endpoint suffix according to cloud environment tags | [tags](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources) would be created in newly created storage account | tag format: 'foo=aaa,bar=bbb' | No | "" diff --git a/pkg/blob/blob.go b/pkg/blob/blob.go index 82a00d41c..0ae551961 100644 --- a/pkg/blob/blob.go +++ b/pkg/blob/blob.go @@ -94,6 +94,7 @@ const ( keyVaultSecretVersionField = "keyvaultsecretversion" storageAccountNameField = "storageaccountname" allowBlobPublicAccessField = "allowblobpublicaccess" + allowSharedKeyAccessField = "allowsharedkeyaccess" requireInfraEncryptionField = "requireinfraencryption" ephemeralField = "csi.storage.k8s.io/ephemeral" podNamespaceField = "csi.storage.k8s.io/pod.namespace" diff --git a/pkg/blob/controllerserver.go b/pkg/blob/controllerserver.go index 35037710f..00bfa833e 100644 --- a/pkg/blob/controllerserver.go +++ b/pkg/blob/controllerserver.go @@ -97,7 +97,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) parameters = make(map[string]string) } var storageAccountType, subsID, resourceGroup, location, account, containerName, containerNamePrefix, protocol, customTags, secretName, secretNamespace, pvcNamespace, tagValueDelimiter string - var isHnsEnabled, requireInfraEncryption, enableBlobVersioning, createPrivateEndpoint, enableNfsV3 *bool + var isHnsEnabled, requireInfraEncryption, enableBlobVersioning, createPrivateEndpoint, enableNfsV3, allowSharedKeyAccess *bool var vnetResourceGroup, vnetName, subnetName, accessTier, networkEndpointType, storageEndpointSuffix, fsGroupChangePolicy string var matchTags, useDataPlaneAPI, getLatestAccountKey bool var softDeleteBlobs, softDeleteContainers int32 @@ -171,6 +171,12 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) if strings.EqualFold(v, trueValue) { allowBlobPublicAccess = pointer.Bool(true) } + case allowSharedKeyAccessField: + var boolValue bool + if boolValue, err = strconv.ParseBool(v); err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in volume context", allowSharedKeyAccessField, v) + } + allowSharedKeyAccess = pointer.Bool(boolValue) case requireInfraEncryptionField: if strings.EqualFold(v, trueValue) { requireInfraEncryption = pointer.Bool(true) @@ -310,6 +316,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) storageEndpointSuffix = d.getStorageEndPointSuffix() } + if storeAccountKey && !pointer.BoolDeref(allowSharedKeyAccess, true) { + return nil, status.Errorf(codes.InvalidArgument, "storeAccountKey is not supported for account with shared access key disabled") + } + accountOptions := &azure.AccountOptions{ Name: account, Type: storageAccountType, @@ -324,6 +334,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) IsHnsEnabled: isHnsEnabled, EnableNfsV3: enableNfsV3, AllowBlobPublicAccess: allowBlobPublicAccess, + AllowSharedKeyAccess: allowSharedKeyAccess, RequireInfrastructureEncryption: requireInfraEncryption, VNetResourceGroup: vnetResourceGroup, VNetName: vnetName, diff --git a/test/e2e/dynamic_provisioning_test.go b/test/e2e/dynamic_provisioning_test.go index 05a09a659..02dfb3b03 100644 --- a/test/e2e/dynamic_provisioning_test.go +++ b/test/e2e/dynamic_provisioning_test.go @@ -585,9 +585,10 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() { CSIDriver: testDriver, Pods: pods, StorageClassParameters: map[string]string{ - "skuName": "Premium_LRS", - "protocol": "nfs", - "mountPermissions": "0", + "skuName": "Premium_LRS", + "protocol": "nfs", + "mountPermissions": "0", + "allowSharedKeyAccess": "false", }, } test.Run(ctx, cs, ns)