Gallery › Key Vault › Azure Community Policy
Audit when a given service principal is not assigned to the Key Vault data plane
Converted Policy Audit Disabled Mode All Version 1.0.0
Audit when a specified AAD object is not granted permissions to secrets, certs, or keys stored in a Key Vault through data plane access policies. This policy will not validate the permissions granted by the access policy, only the existance of at least one access policy for that object.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 51 lines
{
"name": "bd9473dd-0ab1-45a0-9776-ad76482b93e6",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit when a given service principal is not assigned to the Key Vault data plane",
"description": "Audit when a specified AAD object is not granted permissions to secrets, certs, or keys stored in a Key Vault through data plane access policies. This policy will not validate the permissions granted by the access policy, only the existance of at least one access policy for that object.",
"metadata": {
"version": "1.0.0",
"category": "Key Vault"
},
"mode": "All",
"parameters": {
"aadObjectId": {
"type": "String",
"metadata": {
"displayName": "AAD Object ID",
"description": "The objectId of the AAD user, group, or service principal to check."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.KeyVault/vaults"
},
{
"field": "Microsoft.Keyvault/vaults/accessPolicies[*].objectId",
"notEquals": "[parameters('aadObjectId')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawbd9473dd-0ab1-45a0-9776-ad76482b93e6.bylaw.ps1 · 34 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'bd9473dd-0ab1-45a0-9776-ad76482b93e6' {
Properties @{
DisplayName = 'Audit when a given service principal is not assigned to the Key Vault data plane'
Description = 'Audit when a specified AAD object is not granted permissions to secrets, certs, or keys stored in a Key Vault through data plane access policies. This policy will not validate the permissions granted by the access policy, only the existance of at least one access policy for that object.'
Version = '1.0.0'
Category = 'Key Vault'
Mode = 'All'
}
Parameter AadObjectId @{
Type = 'String'
DisplayName = 'AAD Object ID'
Description = 'The objectId of the AAD user, group, or service principal to check.'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.KeyVault/vaults' {
Require 'accessPolicies and objectId are as required' {
Count 'accessPolicies[*]' -Where {
Field objectId | Must -Be (Param AadObjectId)
} | Must -Not -Be 0
}
}
Effect (Param Effect)
}Source: policyDefinitions/Key Vault/audit-when-a-given-service-principal-is-not-assigned-to-the-key-vault-data-plane/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw