首先,您可以将use the Azure portal 本身用于存储 Blob 数据贡献者、存储 Blob 数据所有者,其中Azure role assignment condition 可以作为附加检查,您可以选择添加到您的角色分配中以提供更多fine-grained access control.
Add or edit Azure role assignment conditions :PORTAL
点击添加条件进一步细化基于存储属性的角色分配。
然后,您可以添加资源和条件,例如:如果所选用户尝试读取没有 Project=Cascade 标记的 blob,则不允许访问。
•资源表示该属性在资源上,例如container name. 您必须键入名称并且不会列出下拉列表来选择 blob。
这也可以从ARM template 完成。
以下模板显示了如何为存储 Blob 数据读取者角色分配条件。条件检查容器名称是否等于“blob-example-container”,可以用资源给出@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'blobs-example-container'
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"principalId": {
"type": "string",
"metadata": {
"description": "Principal ID to assign the role to"
}
},
"principalType": {
"type": "string",
"metadata": {
"description": "Type of principal"
}
},
"roleAssignmentGuid": {
"type": "string",
"defaultValue": "[newGuid()]",
"metadata": {
"description": "New GUID used to identify the role assignment"
}
}
},
"variables": {
"StorageBlobDataReader": "[concat(subscription().Id, '/providers/Microsoft.Authorization/roleDefinitions/2a2b9908-6ea1-4ae2-8e65-a410df84e7d1')]" // ID for Storage Blob Data Reader role, but can be any valid role ID
},
"resources": [
{
"name": "[parameters('roleAssignmentGuid')]",
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview", // API version to call the role assignment PUT.
"properties": {
"roleDefinitionId": "[variables('StorageBlobDataReader')]",
"principalId": "[parameters('principalId')]",
"principalType": "[parameters('principalType')]",
"description": "Role assignment condition created with an ARM template",
"condition": "((!(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read'})) OR (@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'blobs-example-container'))", // Role assignment condition
"conditionVersion": "2.0"
}
}
]
}
但除了使用time-bound setting, approval workflow, audit trail, and so on 以及细粒度条件来保护和限制用户之外,您可能需要使用 PIM 并添加其他属性,例如 scheduleInfo、管理员访问权限
就像您使用门户或 ARM pim-resource-roles-assign-roles 链接到这里的那个一样
{
"properties": {
"principalId": "a3bb8764-cb92-4276-9d2a-ca1e895e55ea",
"roleDefinitionId": "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608",
"requestType": "AdminAssign",
"scheduleInfo": {
"startDateTime": "2022-07-05T21:00:00.91Z",
"expiration": {
"type": "AfterDuration",
"endDateTime": null,
"duration": "P365D"
}
},
"condition": "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'",
"conditionVersion": "1.0"
}
}