Gallery › Authorization › Azure Community Policy
Audit Role Assignments For Specific Principal Type
Converted Policy Audit Disabled Mode All Version 1.0.0
This policy audits for any Role Assignments for a specific Principal Type (e.g. User/Group/ServicePrincipal).
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 57 lines
{
"name": "c999c8d5-6387-4b34-b3a4-0eb8a07af5ee",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit Role Assignments For Specific Principal Type",
"description": "This policy audits for any Role Assignments for a specific Principal Type (e.g. User/Group/ServicePrincipal).",
"metadata": {
"version": "1.0.0",
"category": "Authorization"
},
"mode": "All",
"parameters": {
"principalType": {
"type": "String",
"metadata": {
"description": "Which principalType to audit against e.g. 'User, Group, ServicePrincipal'",
"displayName": "principalType"
},
"allowedValues": [
"User",
"Group",
"ServicePrincipal"
],
"defaultValue": "User"
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"equals": "Microsoft.Authorization/roleAssignments",
"field": "type"
},
{
"equals": "[parameters('principalType')]",
"field": "Microsoft.Authorization/roleAssignments/principalType"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawc999c8d5-6387-4b34-b3a4-0eb8a07af5ee.bylaw.ps1 · 33 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'c999c8d5-6387-4b34-b3a4-0eb8a07af5ee' {
Properties @{
DisplayName = 'Audit Role Assignments For Specific Principal Type'
Description = 'This policy audits for any Role Assignments for a specific Principal Type (e.g. User/Group/ServicePrincipal).'
Version = '1.0.0'
Category = 'Authorization'
Mode = 'All'
}
Parameter PrincipalType @{
AllowedValues = @('User', 'Group', 'ServicePrincipal')
Default = 'User'
DisplayName = 'principalType'
Description = 'Which principalType to audit against e.g. ''User, Group, ServicePrincipal'''
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Authorization/roleAssignments' {
Require 'principalType is not the PrincipalType parameter' {
Field principalType | Must -Not -Be (Param PrincipalType) -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/Authorization/audit-role-assignments-for-specific-principal-type/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw