Gallery › API Management › Azure built-in policies
Modify API Management to disable username and password authentication
Converted Policy Modify Mode All Version 1.1.0
To better secure developer portal user accounts and their credentials, configure user authentication through Azure AD or Azure AD B2C identity providers and disable the default username and password authentication.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONBasicAuthDisabled_Modify.json · 61 lines
{
"properties": {
"displayName": "Modify API Management to disable username and password authentication",
"policyType": "BuiltIn",
"mode": "All",
"description": "To better secure developer portal user accounts and their credentials, configure user authentication through Azure AD or Azure AD B2C identity providers and disable the default username and password authentication.",
"metadata": {
"version": "1.1.0",
"category": "API Management"
},
"version": "1.1.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "To better secure developer portal user accounts and their credentials, configure user authentication through Azure AD or Azure AD B2C identity providers and disable the default username and password authentication."
},
"allowedValues": [
"Modify"
],
"defaultValue": "Modify"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ApiManagement/service/portalconfigs"
},
{
"field": "Microsoft.ApiManagement/service/portalconfigs/enableBasicAuth",
"notEquals": "false"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"conflictEffect": "audit",
"operations": [
{
"operation": "addOrReplace",
"field": "Microsoft.ApiManagement/service/portalconfigs/enableBasicAuth",
"value": false
}
]
}
}
},
"versions": [
"1.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/1b0d74ac-4b43-4c39-a15f-594385adc38d",
"name": "1b0d74ac-4b43-4c39-a15f-594385adc38d"
}Bylaw1b0d74ac-4b43-4c39-a15f-594385adc38d.bylaw.ps1 · 30 lines
# Converted from BasicAuthDisabled_Modify.json by ConvertTo-Bylaw.
Policy '1b0d74ac-4b43-4c39-a15f-594385adc38d' {
Properties @{
DisplayName = 'Modify API Management to disable username and password authentication'
Description = 'To better secure developer portal user accounts and their credentials, configure user authentication through Azure AD or Azure AD B2C identity providers and disable the default username and password authentication.'
Version = '1.1.0'
Category = 'API Management'
PolicyVersion = '1.1.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Modify')
Default = 'Modify'
DisplayName = 'Effect'
Description = 'To better secure developer portal user accounts and their credentials, configure user authentication through Azure AD or Azure AD B2C identity providers and disable the default username and password authentication.'
}
Resource 'Microsoft.ApiManagement/service/portalconfigs' {
Require 'enableBasicAuth is false' {
Field enableBasicAuth | Must -Be 'false'
}
}
Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
Field enableBasicAuth | AddOrReplace $false
}
}Source: built-in-policies/policyDefinitions/API Management/BasicAuthDisabled_Modify.json in Azure/azure-policy, under the MIT licence.
Bylaw