Skip to content

Commit 0e638cc

Browse files
authored
Merge pull request #272195 from rolyon/rolyon-rbac-constrained-delegation-edit-conditions
[Azure ABAC] Edit conditions for delegate role assignment management
2 parents 491be85 + 15b7d79 commit 0e638cc

14 files changed

+119
-12
lines changed

articles/role-based-access-control/conditions-authorization-actions-attributes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ manager: amycolannino
66
ms.service: role-based-access-control
77
ms.subservice: conditions
88
ms.topic: conceptual
9-
ms.date: 01/30/2024
9+
ms.date: 04/15/2024
1010
ms.author: rolyon
1111
#Customer intent: As a dev, devops, or it admin, I want to
1212
---
@@ -55,7 +55,7 @@ This section lists the authorization attributes you can use in your condition ex
5555
> | **Attribute** | `Microsoft.Authorization/roleAssignments:RoleDefinitionId` |
5656
> | **Attribute source** | Request<br/>Resource |
5757
> | **Attribute type** | GUID |
58-
> | **Operators** | [GuidEquals](conditions-format.md#guid-comparison-operators)<br/>[GuidNotEquals](conditions-format.md#guid-comparison-operators)<br/>[ForAnyOfAnyValues:GuidEquals](conditions-format.md#foranyofanyvalues)<br/>[ForAnyOfAnyValues:GuidNotEquals](conditions-format.md#foranyofanyvalues) |
58+
> | **Operators** | [GuidEquals](conditions-format.md#guid-comparison-operators)<br/>[GuidNotEquals](conditions-format.md#guid-comparison-operators)<br/>[ForAnyOfAnyValues:GuidEquals](conditions-format.md#foranyofanyvalues)<br/>[ForAnyOfAllValues:GuidNotEquals](conditions-format.md#foranyofallvalues) |
5959
> | **Examples** | `@Request[Microsoft.Authorization/roleAssignments:RoleDefinitionId] ForAnyOfAnyValues:GuidEquals {b24988ac-6180-42a0-ab88-20f7382dd24c, acdd72a7-3385-48ef-bd42-f606fba81ae7}`<br/>[Example: Constrain roles](delegate-role-assignments-examples.md#example-constrain-roles) |
6060
6161
### Principal ID
@@ -68,7 +68,7 @@ This section lists the authorization attributes you can use in your condition ex
6868
> | **Attribute** | `Microsoft.Authorization/roleAssignments:PrincipalId` |
6969
> | **Attribute source** | Request<br/>Resource |
7070
> | **Attribute type** | GUID |
71-
> | **Operators** | [GuidEquals](conditions-format.md#guid-comparison-operators)<br/>[GuidNotEquals](conditions-format.md#guid-comparison-operators)<br/>[ForAnyOfAnyValues:GuidEquals](conditions-format.md#foranyofanyvalues)<br/>[ForAnyOfAnyValues:GuidNotEquals](conditions-format.md#foranyofanyvalues) |
71+
> | **Operators** | [GuidEquals](conditions-format.md#guid-comparison-operators)<br/>[GuidNotEquals](conditions-format.md#guid-comparison-operators)<br/>[ForAnyOfAnyValues:GuidEquals](conditions-format.md#foranyofanyvalues)<br/>[ForAnyOfAllValues:GuidNotEquals](conditions-format.md#foranyofallvalues) |
7272
> | **Examples** | `@Request[Microsoft.Authorization/roleAssignments:PrincipalId] ForAnyOfAnyValues:GuidEquals {28c35fea-2099-4cf5-8ad9-473547bc9423, 86951b8b-723a-407b-a74a-1bca3f0c95d0}`<br/>[Example: Constrain roles and specific groups](delegate-role-assignments-examples.md#example-constrain-roles-and-specific-groups) |
7373
7474
### Principal type
@@ -82,7 +82,7 @@ This section lists the authorization attributes you can use in your condition ex
8282
> | **Attribute source** | Request<br/>Resource |
8383
> | **Attribute type** | STRING |
8484
> | **Values** | User<br/>ServicePrincipal<br/>Group |
85-
> | **Operators** | [StringEqualsIgnoreCase](conditions-format.md#stringequals)<br/>[StringNotEqualsIgnoreCase](conditions-format.md#stringnotequals)<br/>[ForAnyOfAnyValues:StringEqualsIgnoreCase](conditions-format.md#foranyofanyvalues)<br/>[ForAnyOfAnyValues:StringNotEqualsIgnoreCase](conditions-format.md#foranyofanyvalues) |
85+
> | **Operators** | [StringEqualsIgnoreCase](conditions-format.md#stringequals)<br/>[StringNotEqualsIgnoreCase](conditions-format.md#stringnotequals)<br/>[ForAnyOfAnyValues:StringEqualsIgnoreCase](conditions-format.md#foranyofanyvalues)<br/>[ForAnyOfAllValues:StringNotEqualsIgnoreCase](conditions-format.md#foranyofallvalues) |
8686
> | **Examples** | `@Request[Microsoft.Authorization/roleAssignments:PrincipalType] ForAnyOfAnyValues:StringEqualsIgnoreCase {'User', 'Group'}`<br/>[Example: Constrain roles and principal types](delegate-role-assignments-examples.md#example-constrain-roles-and-principal-types) |
8787
8888
## Next steps

articles/role-based-access-control/conditions-role-assignments-portal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Once you have the Add role assignment condition page open, you can review the ba
150150

151151
If you don't see the View/Edit link, be sure you're looking at the same scope as the role assignment.
152152

153-
![Role assignment list with View/Edit link for condition.](./media/conditions-role-assignments-portal/condition-role-assignments-list-edit.png)
153+
![Role assignment list with View/Edit link for condition.](./media/shared/condition-role-assignments-list-edit.png)
154154

155155
The Add role assignment condition page appears.
156156

articles/role-based-access-control/conditions-role-assignments-powershell.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: role-based-access-control
77
ms.subservice: conditions
88
ms.topic: how-to
99
ms.custom: devx-track-azurepowershell
10-
ms.date: 10/24/2022
10+
ms.date: 04/15/2024
1111
ms.author: rolyon
1212
---
1313

@@ -162,6 +162,37 @@ ConditionVersion : 2.0
162162
Condition : ((!(ActionMatches{'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read'})) OR (@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'blobs-example-container' OR @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringEquals 'blobs-example-container2'))
163163
```
164164

165+
### Edit conditions in multiple role assignments
166+
167+
If you need to make the same update to multiple role assignments, you can use a loop. The following commands perform the following task:
168+
169+
- Finds role assignments in a subscription with `<find-condition-string-1>` or `<find-condition-string-2>` strings in the condition.
170+
171+
```azurepowershell
172+
$tenantId = "<your-tenant-id>"
173+
$subscriptionId = "<your-subscription-id>";
174+
$scope = "/subscriptions/$subscriptionId"
175+
$findConditionString1 = "<find-condition-string-1>"
176+
$findConditionString2 = "<find-condition-string-2>"
177+
Connect-AzAccount -TenantId $tenantId -SubscriptionId $subscriptionId
178+
$roleAssignments = Get-AzRoleAssignment -Scope $scope
179+
$foundRoleAssignments = $roleAssignments | Where-Object { ($_.Condition -Match $findConditionString1) -Or ($_.Condition -Match $findConditionString2) }
180+
```
181+
182+
The following commands perform the following tasks:
183+
184+
- In the condition of the found role assignments, replaces `<condition-string>` with `<replace-condition-string>`.
185+
- Updates the role assignments with the changes.
186+
187+
```azurepowershell
188+
$conditionString = "<condition-string>"
189+
$conditionStringReplacement = "<condition-string-replacement>"
190+
$updatedRoleAssignments = $foundRoleAssignments | ForEach-Object { $_.Condition = $_.Condition -replace $conditionString, $conditionStringReplacement; $_ }
191+
$updatedRoleAssignments | ForEach-Object { Set-AzRoleAssignment -InputObject $_ -PassThru }
192+
```
193+
194+
If strings include special characters, such as square brackets ([ ]), you'll need to escape these characters with a backslash (\\).
195+
165196
## List a condition
166197
167198
To list a role assignment condition, use [Get-AzRoleAssignment](/powershell/module/az.resources/get-azroleassignment). For more information, see [List Azure role assignments using Azure PowerShell](role-assignments-list-powershell.md).

articles/role-based-access-control/conditions-troubleshoot.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: role-based-access-control
77
ms.subservice: conditions
88
ms.topic: troubleshooting
99
ms.custom: devx-track-azurepowershell, devx-track-azurecli
10-
ms.date: 02/27/2024
10+
ms.date: 04/15/2024
1111
ms.author: rolyon
1212
---
1313

@@ -65,6 +65,35 @@ Fix any [condition format or syntax](conditions-format.md) issues. Alternatively
6565

6666
## Issues in the visual editor
6767

68+
### Symptom - Condition editor appears when editing a condition
69+
70+
You created a condition using a template described in [Delegate Azure role assignment management to others with conditions](./delegate-role-assignments-portal.md). When you try to edit the condition, you see the advanced condition editor.
71+
72+
:::image type="content" source="./media/conditions-troubleshoot/condition-editor.png" alt-text="Screenshot of condition editor that shows options to edit a condition." lightbox="./media/conditions-troubleshoot/condition-editor.png":::
73+
74+
When you previously edited the condition, you edited using the condition template.
75+
76+
:::image type="content" source="./media/shared/condition-templates-edit.png" alt-text="Screenshot of condition templates with matching template enabled." lightbox="./media/shared/condition-templates-edit.png":::
77+
78+
**Cause**
79+
80+
The condition doesn't match the pattern for the template.
81+
82+
**Solution 1**
83+
84+
Edit the condition to match one of the following template patterns.
85+
86+
| Template | Condition |
87+
| --- | --- |
88+
| Constrain roles | [Example: Constrain roles](delegate-role-assignments-examples.md#example-constrain-roles) |
89+
| Constrain roles and principal types | [Example: Constrain roles and principal types](delegate-role-assignments-examples.md#example-constrain-roles-and-principal-types) |
90+
| Constrain roles and principals | [Example: Constrain roles and specific groups](delegate-role-assignments-examples.md#example-constrain-roles-and-specific-groups) |
91+
| Allow all except specific roles | [Example: Allow most roles, but don't allow others to assign roles](delegate-role-assignments-examples.md#example-allow-most-roles-but-dont-allow-others-to-assign-roles) |
92+
93+
**Solution 2**
94+
95+
Delete the condition and recreate it using the steps at [Delegate Azure role assignment management to others with conditions](./delegate-role-assignments-portal.md).
96+
6897
### Symptom - Principal does not appear in Attribute source
6998

7099
When you try to add a role assignment with a condition, **Principal** doesn't appear in the **Attribute source** list.

articles/role-based-access-control/delegate-role-assignments-examples.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: role-based-access-control
77
ms.subservice: conditions
88
ms.topic: conceptual
99
ms.custom: devx-track-azurepowershell
10-
ms.date: 01/30/2024
10+
ms.date: 04/15/2024
1111
ms.author: rolyon
1212
#Customer intent: As a dev, devops, or it admin, I want to learn about the conditions so that I write more complex conditions.
1313
---
@@ -694,7 +694,13 @@ You must add this condition to any role assignments for the delegate that includ
694694

695695
# [Template](#tab/template)
696696

697-
None
697+
Here are the settings to add this condition using the Azure portal and a condition template.
698+
699+
> [!div class="mx-tableFixed"]
700+
> | Condition | Setting |
701+
> | --- | --- |
702+
> | Template | Allow all except specific roles |
703+
> | Exclude roles | [Owner](built-in-roles.md#owner)<br/>[Role Based Access Control Administrator](built-in-roles.md#role-based-access-control-administrator)<br/>[User Access Administrator](built-in-roles.md#user-access-administrator) |
698704
699705
# [Condition editor](#tab/condition-editor)
700706

articles/role-based-access-control/delegate-role-assignments-portal.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ manager: amycolannino
66
ms.service: role-based-access-control
77
ms.subservice: conditions
88
ms.topic: how-to
9-
ms.date: 01/30/2024
9+
ms.date: 04/15/2024
1010
ms.author: rolyon
1111
#Customer intent: As a dev, devops, or it admin, I want to delegate Azure role assignment management to other users who are closer to the decision, but want to limit the scope of the role assignments.
1212
---
@@ -73,6 +73,7 @@ There are two ways that you can add a condition. You can use a condition templat
7373
| Constrain roles | Allow user to only assign roles you select |
7474
| Constrain roles and principal types | Allow user to only assign roles you select<br/>Allow user to only assign these roles to principal types you select (users, groups, or service principals) |
7575
| Constrain roles and principals | Allow user to only assign roles you select<br/>Allow user to only assign these roles to principals you select |
76+
| Allow all except specific roles | Allow user to assign all roles except the roles you select |
7677

7778
1. In the configure pane, add the required configurations.
7879

@@ -135,7 +136,7 @@ If the condition templates don't work for your scenario or if you want more cont
135136

136137
| Attribute | Common operator |
137138
| --- | --- |
138-
| **Role definition ID** | [ForAnyOfAnyValues:GuidEquals](conditions-format.md#foranyofanyvalues) |
139+
| **Role definition ID** | [ForAnyOfAnyValues:GuidEquals](conditions-format.md#foranyofanyvalues)<br/>[ForAnyOfAllValues:GuidNotEquals](conditions-format.md#foranyofallvalues) |
139140
| **Principal ID** | [ForAnyOfAnyValues:GuidEquals](conditions-format.md#foranyofanyvalues) |
140141
| **Principal type** | [ForAnyOfAnyValues:StringEqualsIgnoreCase](conditions-format.md#foranyofanyvalues) |
141142

@@ -176,6 +177,38 @@ If the condition templates don't work for your scenario or if you want more cont
176177

177178
If the delegate attempts to assign a role that is outside the conditions using an API, the role assignment fails with an error. For more information, see [Symptom - Unable to assign a role](./troubleshooting.md#symptom---unable-to-assign-a-role).
178179

180+
## Edit a condition
181+
182+
There are two ways that you can edit a condition. You can use the condition template or you can use the condition editor.
183+
184+
1. In the Azure portal, open **Access control (IAM)** page for the role assignment that has a condition that you want to view, edit, or delete.
185+
186+
1. Select the **Role assignments** tab and find the role assignment.
187+
188+
1. In the **Condition** column, select **View/Edit**.
189+
190+
If you don't see the **View/Edit** link, be sure you're looking at the same scope as the role assignment.
191+
192+
:::image type="content" source="./media/shared/condition-role-assignments-list-edit.png" alt-text="Screenshot of role assignment list with View/Edit link for condition." lightbox="./media/shared/condition-role-assignments-list-edit.png":::
193+
194+
The **Add role assignment condition** page appears. This page will look different depending on whether the condition matches an existing template.
195+
196+
1. If the condition matches an existing template, select **Configure** to edit the condition.
197+
198+
:::image type="content" source="./media/shared/condition-templates-edit.png" alt-text="Screenshot of condition templates with matching template enabled." lightbox="./media/shared/condition-templates-edit.png":::
199+
200+
1. If the condition doesn't match an existing template, use the advanced condition editor to edit the condition.
201+
202+
For example, to edit a condition, scroll down to the build expression section and update the attributes, operator, or values.
203+
204+
:::image type="content" source="./media/delegate-role-assignments-portal/condition-editor-build-expression.png" alt-text="Screenshot of condition editor that shows options to edit build expression." lightbox="./media/delegate-role-assignments-portal/condition-editor-build-expression.png":::
205+
206+
To edit the condition directly, select the **Code** editor type and then edit the code for the condition.
207+
208+
:::image type="content" source="./media/delegate-role-assignments-portal/condition-editor-code.png" alt-text="Screenshot of condition editor that shows Code editor type." lightbox="./media/delegate-role-assignments-portal/condition-editor-code.png":::
209+
210+
1. When finished, click **Save** to update the condition.
211+
179212
## Next steps
180213

181214
- [Delegate Azure access management to others](delegate-role-assignments-overview.md)
48.6 KB
Loading
56.4 KB
Loading
51.7 KB
Loading
4.34 KB
Loading

0 commit comments

Comments
 (0)