Bylaw

Gallery › Security Center › Azure built-in policies

API endpoints in Azure API Management should be authenticated

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.1

API endpoints published within Azure API Management should enforce authentication to help minimize security risk. Authentication mechanisms are sometimes implemented incorrectly or are missing. This allows attackers to exploit implementation flaws and to access data. Learn More about the OWASP API Threat for Broken User Authentication here: https://learn.microsoft.com/azure/api-management/mitigate-owasp-api-threats#broken-user-authentication

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

Azure Policy JSONASC_APIMApiEndpointsShouldbeAuthenticated_AINE.json · 53 lines
{
  "properties": {
    "displayName": "API endpoints in Azure API Management should be authenticated",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "API endpoints published within Azure API Management should enforce authentication to help minimize security risk. Authentication mechanisms are sometimes implemented incorrectly or are missing. This allows attackers to exploit implementation flaws and to access data. Learn More about the OWASP API Threat for Broken User Authentication here: https://learn.microsoft.com/azure/api-management/mitigate-owasp-api-threats#broken-user-authentication",
    "metadata": {
      "category": "Security Center",
      "version": "1.0.1"
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.ApiManagement/service/apis/operations"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "91af2040-7874-4659-abf0-578e1f8d07dc",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.1",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/8ac833bd-f505-48d5-887e-c993a1d3eea0",
  "name": "8ac833bd-f505-48d5-887e-c993a1d3eea0"
}
Bylaw8ac833bd-f505-48d5-887e-c993a1d3eea0.bylaw.ps1 · 27 lines
# Converted from ASC_APIMApiEndpointsShouldbeAuthenticated_AINE.json by ConvertTo-Bylaw.
Policy '8ac833bd-f505-48d5-887e-c993a1d3eea0' {

    Properties @{
        DisplayName   = 'API endpoints in Azure API Management should be authenticated'
        Description   = 'API endpoints published within Azure API Management should enforce authentication to help minimize security risk. Authentication mechanisms are sometimes implemented incorrectly or are missing. This allows attackers to exploit implementation flaws and to access data. Learn More about the OWASP API Threat for Broken User Authentication here: https://learn.microsoft.com/azure/api-management/mitigate-owasp-api-threats#broken-user-authentication'
        Category      = 'Security Center'
        Version       = '1.0.1'
        PolicyVersion = '1.0.1'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.ApiManagement/service/apis/operations'

    AuditIfNotExists 'Microsoft.Security/assessments' -Name '91af2040-7874-4659-abf0-578e1f8d07dc' -Effect (Param Effect) {
        Require 'status.code is one of 2 values' {
            Field status.code | Must -BeIn @('NotApplicable', 'Healthy')
        }
    }
}

Source: built-in-policies/policyDefinitions/Security Center/ASC_APIMApiEndpointsShouldbeAuthenticated_AINE.json in Azure/azure-policy, under the MIT licence.