Ask Your Question
0

Can you develop an Azure policy that denies role assignments to specific principal types, unless they are authorized by designated users?

asked 2022-09-08 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-17 05:00:00 +0000

pufferfish gravatar image

Yes, it is possible to develop an Azure policy that denies role assignments to specific principal types unless they are authorized by designated users.

Here is an example of a policy definition that accomplishes this:

{
  "mode": "Indexed",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Authorization/roleAssignments"
        },
        {
          "not": {
            "field": "principalType",
            "equals": "ServicePrincipal"
          }
        }
      ]
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {
    "authorizedUsers": {
      "type": "Array",
      "metadata": {
        "description": "List of authorized users who can assign roles to non-service principals"
      }
    }
  }
}

This policy denies any role assignments where the principal type is not a Service Principal. However, there is a parameter called authorizedUsers that allows for specific users to be authorized to assign roles to non-service principals.

To use this policy, you would need to assign it to a scope (such as a subscription or resource group), and include the list of authorized users as a parameter when you create the policy assignment.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-09-08 11:00:00 +0000

Seen: 7 times

Last updated: Jun 17 '21