-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Role] az role assignment create
: Do not invoke Graph API if --assignee-principal-type
is provided
#19219
Conversation
@@ -147,7 +147,7 @@ def create_role_assignment(cmd, role, assignee=None, assignee_object_id=None, re | |||
raise CLIError('usage error: --assignee STRING | --assignee-object-id GUID') | |||
|
|||
if assignee_principal_type and not assignee_object_id: | |||
raise CLIError('usage error: --assignee-object-id GUID [--assignee-principal-type]') | |||
raise CLIError('usage error: --assignee-object-id GUID --assignee-principal-type TYPE') |
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.
As --assignee-object-id
is initially designed to bypass Graph call, we encourage the user to use --assignee-object-id
along with --assignee-principal-type
. Specifying --assignee-object-id
without --assignee-principal-type
is only for backward compatibility.
# Try best to get principal type | ||
logger.warning('RBAC service might reject creating role assignment without --assignee-principal-type ' | ||
'in the future. Better to specify --assignee-principal-type manually.') |
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.
Encourage the user to specify --assignee-principal-type
.
Role |
logger.warning('Failed to query %s by invoking Graph API. ' | ||
'If you don\'t have permission to query Graph API, please ' | ||
'specify --assignee-object-id and --assignee-principal-type.', assignee) |
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.
Even though --assignee
accepts object ID, we want to avoid such usage by encouraging --assignee-object-id
and --assignee-principal-type
.
Fix #19217, Refine #17669
Symptom
--assignee-principal-type
is not honored if AD Graph query for--assignee-object-id
succeeds. See--assignee-principal-type
is not honored if Graph query for--assignee-object-id
succeeds #19217for more details.
Change
Do not invoke Graph API if
--assignee-principal-type
is provided.As
--assignee-object-id
is initially designed to bypass Graph call, we recommend the user to provide--assignee-principal-type
to avoid Graph call. Otherwise if--assignee-principal-type
is not provided, CLI will try best to query Graph API to auto-complete--assignee-principal-type
.Testing Guide
Create a service principal that doesn't have permission to query Graph API. Then log in with that service principal.
Specify Object ID as
--assignee
:Specify Object ID as
--assignee-object-id
:Specify Object ID as
--assignee-object-id
and--assignee-principal-type
: