Bylaw

Gallery › Media Services › Azure built-in policies

[Deprecated]: Azure Media Services content key policies should use token authentication

Uses Condition Policy Audit Deny Disabled Mode All Version 1.1.0-deprecated Deprecated

This policy is deprecated because Media Services retirement. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.

ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.

Azure Policy JSONContentKeyPolicies_RequireTokenAuth_Audit.json · 101 lines
{
  "properties": {
    "displayName": "[Deprecated]: Azure Media Services content key policies should use token authentication",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "This policy is deprecated because Media Services retirement. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
    "metadata": {
      "version": "1.1.0-deprecated",
      "category": "Media Services",
      "deprecated": true
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Disabled",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      },
      "openIdConnectDiscoveryDocument": {
        "type": "string",
        "metadata": {
          "displayName": "OpenID Connect discovery document",
          "description": "The permitted OpenID Connect discovery document. When using Microsoft Entra ID, this would be similar to 'https://login.microsoftonline.com/{tenantId}/v2.0/.well-known/openid-configuration', where {tenantId} is replaced with the tenant (directory) ID."
        }
      },
      "issuer": {
        "type": "string",
        "metadata": {
          "displayName": "Issuer",
          "description": "The permitted token issuer. When using Microsoft Entra ID, this would be similar to 'https://sts.windows.net/{tenantId}/', where {tenantId} is replaced with the tenant (directory) ID."
        }
      },
      "audience": {
        "type": "string",
        "metadata": {
          "displayName": "Audience",
          "description": "The permitted token audience. When using Microsoft Entra ID, this is the Application ID URI of the resource application."
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Media/mediaservices/contentKeyPolicies"
          },
          {
            "count": {
              "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*]",
              "where": {
                "not": {
                  "allOf": [
                    {
                      "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction",
                      "exists": "true"
                    },
                    {
                      "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.restrictionTokenType",
                      "matchInsensitively": "Jwt"
                    },
                    {
                      "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.openIdConnectDiscoveryDocument",
                      "like": "[parameters('openIdConnectDiscoveryDocument')]"
                    },
                    {
                      "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.issuer",
                      "like": "[parameters('issuer')]"
                    },
                    {
                      "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.audience",
                      "like": "[parameters('audience')]"
                    }
                  ]
                }
              }
            },
            "greater": 0
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/daccf7e4-9808-470c-a848-1c5b582a1afb",
  "name": "daccf7e4-9808-470c-a848-1c5b582a1afb"
}
Bylawdaccf7e4-9808-470c-a848-1c5b582a1afb.bylaw.ps1 · 45 lines
# Converted from ContentKeyPolicies_RequireTokenAuth_Audit.json by ConvertTo-Bylaw.
Policy 'daccf7e4-9808-470c-a848-1c5b582a1afb' {

    Properties @{
        DisplayName   = '[Deprecated]: Azure Media Services content key policies should use token authentication'
        Description   = 'This policy is deprecated because Media Services retirement. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.'
        Version       = '1.1.0-deprecated'
        Category      = 'Media Services'
        Deprecated    = $true
        PolicyVersion = '1.1.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter OpenIdConnectDiscoveryDocument @{
        Type        = 'string'
        DisplayName = 'OpenID Connect discovery document'
        Description = 'The permitted OpenID Connect discovery document. When using Microsoft Entra ID, this would be similar to ''https://login.microsoftonline.com/{tenantId}/v2.0/.well-known/openid-configuration'', where {tenantId} is replaced with the tenant (directory) ID.'
    }
    Parameter Issuer @{
        Type        = 'string'
        DisplayName = 'Issuer'
        Description = 'The permitted token issuer. When using Microsoft Entra ID, this would be similar to ''https://sts.windows.net/{tenantId}/'', where {tenantId} is replaced with the tenant (directory) ID.'
    }
    Parameter Audience @{
        Type        = 'string'
        DisplayName = 'Audience'
        Description = 'The permitted token audience. When using Microsoft Entra ID, this is the Application ID URI of the resource application.'
    }

    Resource 'Microsoft.Media/mediaservices/contentKeyPolicies' {

        Require 'options, options.restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction, options.restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.restrictionTokenType and 3 more are as required' {
            Condition -Violation '{ "count": { "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*]", "where": { "anyOf": [ { "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction", "exists": false }, { "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.restrictionTokenType", "notMatchInsensitively": "Jwt" }, { "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.openIdConnectDiscoveryDocument", "notLike": "[parameters(''openIdConnectDiscoveryDocument'')]" }, { "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.issuer", "notLike": "[parameters(''issuer'')]" }, { "field": "Microsoft.Media/mediaServices/contentKeyPolicies/options[*].restriction.#Microsoft-Media-ContentKeyPolicyTokenRestriction.audience", "notLike": "[parameters(''audience'')]" } ] } }, "greater": 0 }'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Media Services/ContentKeyPolicies_RequireTokenAuth_Audit.json in Azure/azure-policy, under the MIT licence.