Bylaw

Gallery › Storage › Azure Landing Zones Library

File Services with insecure authentication methods should be denied

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

This policy denies the use of insecure authentication methods (NTLMv2) when using File Services on a storage account.

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

Azure Policy JSONDeny-FileServices-InsecureAuth.alz_policy_definition.json · 64 lines
{
  "name": "Deny-FileServices-InsecureAuth",
  "properties": {
    "description": "This policy denies the use of insecure authentication methods (NTLMv2) when using File Services on a storage account.",
    "displayName": "File Services with insecure authentication methods should be denied",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Storage",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "All",
    "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"
      },
      "notAllowedAuthMethods": {
        "allowedValues": [
          "NTLMv2",
          "Kerberos"
        ],
        "defaultValue": "NTLMv2",
        "metadata": {
          "description": "The list of channelEncryption not allowed.",
          "displayName": "Authentication methods supported by server. Valid values are NTLMv2, Kerberos."
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "contains": "[parameters('notAllowedAuthMethods')]",
            "field": "Microsoft.Storage/storageAccounts/fileServices/protocolSettings.smb.authenticationMethods"
          },
          {
            "equals": "Microsoft.Storage/storageAccounts/fileServices",
            "field": "type"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-FileServices-InsecureAuth.bylaw.ps1 · 34 lines
# Converted from Deny-FileServices-InsecureAuth.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-FileServices-InsecureAuth' {

    Properties @{
        DisplayName = 'File Services with insecure authentication methods should be denied'
        Description = 'This policy denies the use of insecure authentication methods (NTLMv2) when using File Services on a storage account.'
        Category    = 'Storage'
        Version     = '1.0.0'
        Mode        = 'All'
        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 NotAllowedAuthMethods @{
        AllowedValues = @('NTLMv2', 'Kerberos')
        Default       = 'NTLMv2'
        DisplayName   = 'Authentication methods supported by server. Valid values are NTLMv2, Kerberos.'
        Description   = 'The list of channelEncryption not allowed.'
    }

    Resource 'Microsoft.Storage/storageAccounts/fileServices' {

        Require 'protocolSettings.smb.authenticationMethods does not contain the NotAllowedAuthMethods parameter' {
            Field protocolSettings.smb.authenticationMethods | Must -Not -ContainText (Param NotAllowedAuthMethods) -IfPresent
        }
    }

    Effect (Param Effect)
}

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