Bylaw

Gallery › Container Registry › Azure built-in policies

Container registries should have anonymous authentication disabled.

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disable anonymous pull for your registry so that data is not accessible by unauthenticated user. Disabling local authentication methods like admin user, repository scoped access tokens and anonymous pull improves security by ensuring that container registries exclusively require Azure Active Directory identities for authentication. Learn more at: https://aka.ms/acr/authentication.

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

Azure Policy JSONACR_AnonymousPullDisabled_AuditDeny.json · 50 lines
{
  "properties": {
    "displayName": "Container registries should have anonymous authentication disabled.",
    "description": "Disable anonymous pull for your registry so that data is not accessible by unauthenticated user. Disabling local authentication methods like admin user, repository scoped access tokens and anonymous pull improves security by ensuring that container registries exclusively require Azure Active Directory identities for authentication. Learn more at: https://aka.ms/acr/authentication.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.0.0",
      "category": "Container Registry"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ContainerRegistry/registries"
          },
          {
            "field": "Microsoft.ContainerRegistry/registries/anonymousPullEnabled",
            "equals": true
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/9f2dea28-e834-476c-99c5-3507b4728395",
  "name": "9f2dea28-e834-476c-99c5-3507b4728395"
}
Bylaw9f2dea28-e834-476c-99c5-3507b4728395.bylaw.ps1 · 28 lines
# Converted from ACR_AnonymousPullDisabled_AuditDeny.json by ConvertTo-Bylaw.
Policy '9f2dea28-e834-476c-99c5-3507b4728395' {

    Properties @{
        DisplayName   = 'Container registries should have anonymous authentication disabled.'
        Description   = 'Disable anonymous pull for your registry so that data is not accessible by unauthenticated user. Disabling local authentication methods like admin user, repository scoped access tokens and anonymous pull improves security by ensuring that container registries exclusively require Azure Active Directory identities for authentication. Learn more at: https://aka.ms/acr/authentication.'
        Version       = '1.0.0'
        Category      = 'Container Registry'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.ContainerRegistry/registries' {

        Require 'anonymousPullEnabled is not true' {
            Field anonymousPullEnabled | Must -Not -Be $true -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Container Registry/ACR_AnonymousPullDisabled_AuditDeny.json in Azure/azure-policy, under the MIT licence.