-
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
Conversation
Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
…ssions Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
ChangeLog.md
Outdated
#### Az.Relay 2.1.2 | ||
* Update the outputs of breaking change announcements. | ||
|
||
#### Az.Resources 8.1.1 |
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.
why you changed this file copilot?
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.
I updated the main ChangeLog.md by mistake. The change has been reverted 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 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 comment
The 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.
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.
{ | ||
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" |
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.
// 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.
@copilot please address the comments |
…e comment Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
|
||
AuthorizationClient.ValidateScope(null, true); | ||
} | ||
|
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.
this test creates arbitrary value for assignment object and performs assert for these arbitrary values, does it make sense copilot?
src/Resources/Resources/ChangeLog.md
Outdated
## 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] |
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.
why you need 2 bullet points when you can do a one liner, copilot?
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.
Pull Request Overview
This PR fixes RoleAssignment cmdlets to properly handle insufficient MSGraph permissions by implementing correct fallback logic to cached principal types instead of immediately defaulting to "Unknown".
Key changes:
- Corrected the priority order for object type determination in role assignment processing
- Applied the fix to both single assignment and batch processing methods
- Added proper changelog documentation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs | Fixed exception handling to use cached principal type fallback instead of immediately setting "Unknown" type |
src/Resources/Resources/ChangeLog.md | Added changelog entry documenting the MSGraph permissions fix |
/azp run azure-powershell - security-tools |
Azure Pipelines successfully started running 1 pipeline(s). |
Fix RoleAssignment cmdlets to properly handle insufficient MSGraph permissions by falling back to cached principal type
Problem Fixed:
The
ToPSRoleAssignment()
method was incorrectly handling insufficient MSGraph permissions. When Active Directory lookup failed due to authorization denied or not found errors, it immediately setObjectType = "Unknown"
instead of following the documented priority order.Root Cause:
AuthorizationClientExtensions.cs
createdPSADObject
withType = UnknownType
when AD lookup failedassignment.PrincipalType
Solution:
assignment.PrincipalType ?? UnknownType
instead of immediately usingUnknownType
Priority Order Now Correctly Implemented:
Files Changed:
src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs
- Core fixsrc/Resources/Resources/ChangeLog.md
- Added changelog entryFixes #28583.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.