Bylaw

Gallery › Cache › Azure Landing Zones Library

Azure Cache for Redis only secure connections should be enabled

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Audit enabling of only connections via SSL to Azure Cache for Redis. Validate both minimum TLS version and enableNonSslPort is disabled. Use of secure connections ensures authentication between the server and the service and protects data in transit from network layer attacks such as man-in-the-middle, eavesdropping, and session-hijacking

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

Azure Policy JSONDeny-Redis-http.alz_policy_definition.json · 73 lines
{
  "name": "Deny-Redis-http",
  "properties": {
    "description": "Audit enabling of only connections via SSL to Azure Cache for Redis. Validate both minimum TLS version and enableNonSslPort is disabled. Use of secure connections ensures authentication between the server and the service and protects data in transit from network layer attacks such as man-in-the-middle, eavesdropping, and session-hijacking",
    "displayName": "Azure Cache for Redis only secure connections should be enabled",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Cache",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.1.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "The effect determines what happens when the policy rule is evaluated to match",
          "displayName": "Effect"
        },
        "type": "String"
      },
      "minimumTlsVersion": {
        "allowedValues": [
          "1.2",
          "1.1",
          "1.0"
        ],
        "defaultValue": "1.2",
        "metadata": {
          "description": "Select minimum TLS version for Azure Cache for Redis.",
          "displayName": "Select minimum TLS version for Azure Cache for Redis."
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Cache/redis",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "equals": "true",
                "field": "Microsoft.Cache/Redis/enableNonSslPort"
              },
              {
                "field": "Microsoft.Cache/Redis/minimumTlsVersion",
                "less": "[parameters('minimumTlsVersion')]"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-Redis-http.bylaw.ps1 · 38 lines
# Converted from Deny-Redis-http.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-Redis-http' {

    Properties @{
        DisplayName = 'Azure Cache for Redis only secure connections should be enabled'
        Description = 'Audit enabling of only connections via SSL to Azure Cache for Redis. Validate both minimum TLS version and enableNonSslPort is disabled. Use of secure connections ensures authentication between the server and the service and protects data in transit from network layer attacks such as man-in-the-middle, eavesdropping, and session-hijacking'
        Category    = 'Cache'
        Version     = '1.1.0'
        Mode        = 'Indexed'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }
    Parameter MinimumTlsVersion @{
        AllowedValues = @('1.2', '1.1', '1.0')
        Default       = '1.2'
        DisplayName   = 'Select minimum TLS version for Azure Cache for Redis.'
        Description   = 'Select minimum TLS version for Azure Cache for Redis.'
    }

    Resource 'Microsoft.Cache/redis' {

        Require 'enableNonSslPort is not true' {
            Field enableNonSslPort | Must -Not -Be 'true' -IfPresent
        }

        Require 'minimumTlsVersion is at least the MinimumTlsVersion parameter' {
            Field minimumTlsVersion | Must -BeGreaterOrEqual (Param MinimumTlsVersion) -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-Redis-http.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.