Bylaw

Gallery › Event Hub › Azure built-in policies

All authorization rules except RootManageSharedAccessKey should be removed from Event Hub namespace

Converted Policy Audit Deny Disabled Mode All Version 1.0.1

Event Hub clients should not use a namespace level access policy that provides access to all queues and topics in a namespace. To align with the least privilege security model, you should create access policies at the entity level for queues and topics to provide access to only the specific entity

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONAuditNamespaceAccessRules_Audit.json · 50 lines
{
  "properties": {
    "displayName": "All authorization rules except RootManageSharedAccessKey should be removed from Event Hub namespace",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Event Hub clients should not use a namespace level access policy that provides access to all queues and topics in a namespace. To align with the least privilege security model, you should create access policies at the entity level for queues and topics to provide access to only the specific entity",
    "metadata": {
      "version": "1.0.1",
      "category": "Event Hub"
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.EventHub/namespaces/authorizationRules"
          },
          {
            "field": "name",
            "notEquals": "RootManageSharedAccessKey"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/b278e460-7cfc-4451-8294-cccc40a940d7",
  "name": "b278e460-7cfc-4451-8294-cccc40a940d7"
}
Bylawb278e460-7cfc-4451-8294-cccc40a940d7.bylaw.ps1 · 29 lines
# Converted from AuditNamespaceAccessRules_Audit.json by ConvertTo-Bylaw.
Policy 'b278e460-7cfc-4451-8294-cccc40a940d7' {

    Properties @{
        DisplayName   = 'All authorization rules except RootManageSharedAccessKey should be removed from Event Hub namespace'
        Description   = 'Event Hub clients should not use a namespace level access policy that provides access to all queues and topics in a namespace. To align with the least privilege security model, you should create access policies at the entity level for queues and topics to provide access to only the specific entity'
        Version       = '1.0.1'
        Category      = 'Event Hub'
        PolicyVersion = '1.0.1'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.EventHub/namespaces/authorizationRules' {

        Require 'name is RootManageSharedAccessKey' {
            Field name | Must -Be 'RootManageSharedAccessKey'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Event Hub/AuditNamespaceAccessRules_Audit.json in Azure/azure-policy, under the MIT licence.