-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Fix RoleAssignment ObjectType fallback for insufficient MSGraph permissions #28584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e64ca77
f64066a
56c9d2b
e378a90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,6 +201,11 @@ | |
| #### Az.Relay 2.1.2 | ||
| * Update the outputs of breaking change announcements. | ||
|
|
||
| #### Az.Resources 8.1.1 | ||
|
||
| * Fixed issue where RoleAssignment cmdlets did not properly handle insufficient MSGraph permissions | ||
| - When Active Directory lookup fails due to insufficient permissions, the cmdlets now fall back to cached principal type instead of immediately using "Unknown" type | ||
| - Fixed issue [#28583] | ||
|
|
||
| #### Az.Resources 8.1.0 | ||
| * Added functionality for cmdlet 'GetAzureResourceGroup'[#27865] | ||
| * Added breaking change announcement for below cmdlets from array to list. | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert the added test in this file as it isn't feasible to mock There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted the test file changes in commit 56c9d2b as it wasn't feasible to mock properly. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,5 +63,32 @@ public void VerifyValidScopes() | |
|
|
||
| AuthorizationClient.ValidateScope(null, true); | ||
| } | ||
|
|
||
|
||
| [Fact] | ||
| [Trait(Category.AcceptanceType, Category.CheckIn)] | ||
| public void ToPSRoleAssignment_ShouldFallbackToCachedPrincipalType_WhenADLookupFails() | ||
| { | ||
| // Arrange | ||
| var assignment = new Microsoft.Azure.Management.Authorization.Models.RoleAssignment( | ||
| id: "/subscriptions/sub-id/providers/Microsoft.Authorization/roleAssignments/assignment-id", | ||
| name: "assignment-name", | ||
| scope: "/subscriptions/sub-id", | ||
| roleDefinitionId: "/subscriptions/sub-id/providers/Microsoft.Authorization/roleDefinitions/role-id", | ||
| principalId: "principal-id", | ||
| principalType: "ServicePrincipal" // This is the cached principal type we want to preserve | ||
| ); | ||
|
|
||
| // Mock clients that will be used (we can't actually mock due to network restrictions, | ||
| // but this test documents the expected behavior) | ||
| // The test would verify that when GetObjectByObjectId throws OdataErrorException with authorization denied, | ||
| // the resulting PSRoleAssignment should have ObjectType = "ServicePrincipal" (from assignment.PrincipalType) | ||
| // instead of "Unknown" | ||
|
|
||
| // This is a documentation test showing the fix - the actual runtime test would require | ||
| // proper mocking infrastructure that isn't available due to build constraints | ||
| Assert.True(true, "Test documents expected behavior: When AD lookup fails due to insufficient permissions, " + | ||
| "ToPSRoleAssignment should use assignment.PrincipalType ('ServicePrincipal') " + | ||
| "instead of immediately falling back to 'Unknown' type."); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ | |
| --> | ||
|
|
||
| ## Upcoming Release | ||
| * Fixed issue where RoleAssignment cmdlets did not properly handle insufficient MSGraph permissions | ||
| - When Active Directory lookup fails due to insufficient permissions, the cmdlets now fall back to cached principal type instead of immediately using "Unknown" type | ||
| - Fixed issue [#28583] | ||
|
||
|
|
||
| ## Version 8.1.0 | ||
| * Added functionality for cmdlet `GetAzureResourceGroup`[#27865] | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -98,7 +98,9 @@ public static PSRoleAssignment ToPSRoleAssignment(this RoleAssignment assignment | |||||||
| { | ||||||||
| if (oe.IsAuthorizationDeniedException() || oe.IsNotFoundException()) | ||||||||
| { | ||||||||
| adObject = new PSADObject() { Id = assignment.PrincipalId, Type = UnknownType}; | ||||||||
| // When AD lookup fails due to insufficient permissions or not found, | ||||||||
| // fall back to cached principal type instead of immediately using "Unknown" | ||||||||
|
||||||||
| // fall back to cached principal type instead of immediately using "Unknown" | |
| // fall back to cached principal type from response, | |
| // then finally fall back to "Unknown" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment as suggested in commit 56c9d2b.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the changes in this file as it is purely generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the main ChangeLog.md changes in commit 56c9d2b.