Gallery › API Management › Azure built-in policies
API Management calls to API backends should be authenticated
Converted Policy Audit Deny Disabled Mode All Version 1.0.1
Calls from API Management to backends should use some form of authentication, whether via certificates or credentials. Does not apply to Service Fabric backends.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONBackendAuth_AuditDeny.json · 82 lines
{
"properties": {
"displayName": "API Management calls to API backends should be authenticated",
"policyType": "BuiltIn",
"mode": "All",
"description": "Calls from API Management to backends should use some form of authentication, whether via certificates or credentials. Does not apply to Service Fabric backends.",
"metadata": {
"version": "1.0.1",
"category": "API Management"
},
"version": "1.0.1",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ApiManagement/service/backends"
},
{
"field": "Microsoft.ApiManagement/service/backends/url",
"exists": "true"
},
{
"field": "Microsoft.ApiManagement/service/backends/protocol",
"equals": "http"
},
{
"allOf": [
{
"anyOf": [
{
"field": "Microsoft.ApiManagement/service/backends/credentials.certificate",
"exists": "false"
},
{
"value": "[length(field('Microsoft.ApiManagement/service/backends/credentials.certificate[*]'))]",
"equals": 0
}
]
},
{
"anyOf": [
{
"field": "Microsoft.ApiManagement/service/backends/credentials.authorization.scheme",
"exists": "false"
},
{
"field": "Microsoft.ApiManagement/service/backends/credentials.authorization.parameter",
"exists": "false"
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"parameters": {
"effect": {
"type": "string",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Disabled",
"Deny"
],
"defaultValue": "Audit"
}
},
"versions": [
"1.0.1"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/c15dcc82-b93c-4dcb-9332-fbf121685b54",
"name": "c15dcc82-b93c-4dcb-9332-fbf121685b54"
}Bylawc15dcc82-b93c-4dcb-9332-fbf121685b54.bylaw.ps1 · 42 lines
# Converted from BackendAuth_AuditDeny.json by ConvertTo-Bylaw.
Policy 'c15dcc82-b93c-4dcb-9332-fbf121685b54' {
Properties @{
DisplayName = 'API Management calls to API backends should be authenticated'
Description = 'Calls from API Management to backends should use some form of authentication, whether via certificates or credentials. Does not apply to Service Fabric backends.'
Version = '1.0.1'
Category = 'API Management'
PolicyVersion = '1.0.1'
Mode = 'All'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('Audit', 'Disabled', 'Deny')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.ApiManagement/service/backends' {
When {
Field url | Must -Exist
Field protocol | Must -Be 'http'
AnyOf {
Field credentials.certificate | Must -Not -Exist
Arm '[length(field(''Microsoft.ApiManagement/service/backends/credentials.certificate[*]''))]' | Must -Be 0
}
}
Require 'credentials.authorization.scheme exists' {
Field credentials.authorization.scheme | Must -Exist
}
Require 'credentials.authorization.parameter exists' {
Field credentials.authorization.parameter | Must -Exist
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/API Management/BackendAuth_AuditDeny.json in Azure/azure-policy, under the MIT licence.
Bylaw