Bylaw

Gallery › Container Registry › Azure built-in policies

Container registries should have local admin account disabled.

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.1

Disable admin account for your registry so that it is not accessible by local admin. 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_AdminAccountDisabled_AuditDeny.json · 50 lines
{
  "properties": {
    "displayName": "Container registries should have local admin account disabled.",
    "description": "Disable admin account for your registry so that it is not accessible by local admin. 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.1",
      "category": "Container Registry"
    },
    "version": "1.0.1",
    "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/adminUserEnabled",
            "equals": true
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/dc921057-6b28-4fbe-9b83-f7bec05db6c2",
  "name": "dc921057-6b28-4fbe-9b83-f7bec05db6c2"
}
Bylawdc921057-6b28-4fbe-9b83-f7bec05db6c2.bylaw.ps1 · 28 lines
# Converted from ACR_AdminAccountDisabled_AuditDeny.json by ConvertTo-Bylaw.
Policy 'dc921057-6b28-4fbe-9b83-f7bec05db6c2' {

    Properties @{
        DisplayName   = 'Container registries should have local admin account disabled.'
        Description   = 'Disable admin account for your registry so that it is not accessible by local admin. 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.1'
        Category      = 'Container Registry'
        PolicyVersion = '1.0.1'
        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 'adminUserEnabled is not true' {
            Field adminUserEnabled | Must -Not -Be $true -IfPresent
        }
    }

    Effect (Param Effect)
}

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