Skip to content

Commit d9c2f3f

Browse files
specialforestk8s-infra-cherrypick-robot
authored andcommitted
feat: add allowSharedKeyAccess parameter
1 parent ebf1dae commit d9c2f3f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

docs/driver-parameters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ containerNamePrefix | specify Azure storage directory prefix created by driver |
3131
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
3232
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)
3333
allowBlobPublicAccess | Allow or disallow public access to all blobs or containers for storage account created by driver | `true`,`false` | No | `false`
34+
allowSharedKeyAccess | Allow or disallow shared key access for storage account created by driver | `true`,`false` | No | `true`
3435
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`
3536
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
3637
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 | ""

pkg/blob/blob.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const (
9494
keyVaultSecretVersionField = "keyvaultsecretversion"
9595
storageAccountNameField = "storageaccountname"
9696
allowBlobPublicAccessField = "allowblobpublicaccess"
97+
allowSharedKeyAccessField = "allowsharedkeyaccess"
9798
requireInfraEncryptionField = "requireinfraencryption"
9899
ephemeralField = "csi.storage.k8s.io/ephemeral"
99100
podNamespaceField = "csi.storage.k8s.io/pod.namespace"

pkg/blob/controllerserver.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
105105
var err error
106106
// set allowBlobPublicAccess as false by default
107107
allowBlobPublicAccess := pointer.Bool(false)
108+
// set allowBlobPublicAccess as true by default
109+
allowSharedKeyAccess := pointer.Bool(true)
108110

109111
containerNameReplaceMap := map[string]string{}
110112

@@ -171,6 +173,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
171173
if strings.EqualFold(v, trueValue) {
172174
allowBlobPublicAccess = pointer.Bool(true)
173175
}
176+
case allowSharedKeyAccessField:
177+
if strings.EqualFold(v, falseValue) {
178+
allowSharedKeyAccess = pointer.Bool(false)
179+
}
174180
case requireInfraEncryptionField:
175181
if strings.EqualFold(v, trueValue) {
176182
requireInfraEncryption = pointer.Bool(true)
@@ -310,6 +316,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
310316
storageEndpointSuffix = d.getStorageEndPointSuffix()
311317
}
312318

319+
if storeAccountKey && !pointer.BoolDeref(allowSharedKeyAccess, false) {
320+
return nil, status.Errorf(codes.InvalidArgument, "storeAccountKey is not supported for account with shared access key disabled")
321+
}
322+
313323
accountOptions := &azure.AccountOptions{
314324
Name: account,
315325
Type: storageAccountType,
@@ -324,6 +334,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
324334
IsHnsEnabled: isHnsEnabled,
325335
EnableNfsV3: enableNfsV3,
326336
AllowBlobPublicAccess: allowBlobPublicAccess,
337+
AllowSharedKeyAccess: allowSharedKeyAccess,
327338
RequireInfrastructureEncryption: requireInfraEncryption,
328339
VNetResourceGroup: vnetResourceGroup,
329340
VNetName: vnetName,

0 commit comments

Comments
 (0)