Gallery › Search › Azure Community Policy
Auth failure should return 403 when in transition from api keys to RBAC authentication
Converted Policy Audit Disabled Mode All Version 1.0.0
Set auth failure mode to https403 for search services in the transition state between using api keys for authentication to RBAC
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 48 lines
{
"type": "Microsoft.Authorization/policyDefinitions",
"name": "e62541ee-b22d-4942-afa0-e15ecb4472da",
"properties": {
"displayName": "Auth failure should return 403 when in transition from api keys to RBAC authentication",
"mode": "All",
"description": "Set auth failure mode to https403 for search services in the transition state between using api keys for authentication to RBAC",
"metadata": {
"category": "Search",
"version": "1.0.0"
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Search/searchServices"
},
{
"field": "Microsoft.Search/searchServices/disableLocalAuth",
"notEquals": "true"
},
{
"field": "Microsoft.Search/searchServices/authOptions.aadOrApiKey.aadAuthFailureMode",
"notEquals": "http403"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawe62541ee-b22d-4942-afa0-e15ecb4472da.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'e62541ee-b22d-4942-afa0-e15ecb4472da' {
Properties @{
DisplayName = 'Auth failure should return 403 when in transition from api keys to RBAC authentication'
Description = 'Set auth failure mode to https403 for search services in the transition state between using api keys for authentication to RBAC'
Category = 'Search'
Version = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Search/searchServices' {
When {
Field disableLocalAuth | Must -Not -Be 'true'
}
Require 'authOptions.aadOrApiKey.aadAuthFailureMode is http403' {
Field authOptions.aadOrApiKey.aadAuthFailureMode | Must -Be 'http403'
}
}
Effect (Param Effect)
}Source: policyDefinitions/Search/return-forbidden-for-auth-failure/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw