Gallery › API for FHIR › Azure built-in policies
CORS should not allow every domain to access your API for FHIR
Converted Policy Audit Disabled Mode Indexed Version 1.1.0
Cross-Origin Resource Sharing (CORS) should not allow all domains to access your API for FHIR. To protect your API for FHIR, remove access for all domains and explicitly define the domains allowed to connect.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONHealthcareAPIs_RestrictCORSAccess_Audit.json · 53 lines
{
"properties": {
"displayName": "CORS should not allow every domain to access your API for FHIR",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Cross-Origin Resource Sharing (CORS) should not allow all domains to access your API for FHIR. To protect your API for FHIR, remove access for all domains and explicitly define the domains allowed to connect.",
"metadata": {
"version": "1.1.0",
"category": "API for FHIR"
},
"version": "1.1.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"audit",
"Audit",
"disabled",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HealthcareApis/services"
},
{
"not": {
"field": "Microsoft.HealthcareApis/services/corsConfiguration.origins[*]",
"notEquals": "*"
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/0fea8f8a-4169-495d-8307-30ec335f387d",
"name": "0fea8f8a-4169-495d-8307-30ec335f387d"
}Bylaw0fea8f8a-4169-495d-8307-30ec335f387d.bylaw.ps1 · 30 lines
# Converted from HealthcareAPIs_RestrictCORSAccess_Audit.json by ConvertTo-Bylaw.
Policy '0fea8f8a-4169-495d-8307-30ec335f387d' {
Properties @{
DisplayName = 'CORS should not allow every domain to access your API for FHIR'
Description = 'Cross-Origin Resource Sharing (CORS) should not allow all domains to access your API for FHIR. To protect your API for FHIR, remove access for all domains and explicitly define the domains allowed to connect.'
Version = '1.1.0'
Category = 'API for FHIR'
PolicyVersion = '1.1.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('audit', 'Audit', 'disabled', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.HealthcareApis/services' {
Require 'corsConfiguration.origins is as required' {
Each 'corsConfiguration.origins[*]' {
Element | Must -Not -Be '*'
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/API for FHIR/HealthcareAPIs_RestrictCORSAccess_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw