-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Role] az ad sp create-for-rbac: Deprecate creating Contributor role assignment by default #16081
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
| def create_service_principal_for_rbac( | ||
| # pylint:disable=too-many-statements,too-many-locals, too-many-branches | ||
| cmd, name=None, years=None, create_cert=False, cert=None, scopes=None, role='Contributor', | ||
| cmd, name=None, years=None, create_cert=False, cert=None, scopes=None, role=None, |
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.
Need to detect whether role is explicitly set and show the warning if not.
If role='Contributor' is used, it won't be possible to detect if role is provided by the user or as the default value.
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.
Another option is to check role.is_default, and show the warning message accordingly. If role is assigned a default value, its type will be knack.validators.DefaultStr which has is_default field indicating whether it is the default value.
| logger.warning(ROLE_ASSIGNMENT_CREATE_WARNING) | ||
| for scope in scopes: | ||
| logger.warning('Creating a role assignment under the scope of "%s"', scope) | ||
| logger.warning("Creating '%s' role assignment under scope '%s'", role, scope) |
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.
Echo the role name to be more explicit and informative.
|
Role |
|
Shall we mark |
No, as it will be become the default behavior, instead of deprecated. We now recommend the user to use it! Marking it as deprecated will further confuse the user. We can marked it as deprecated AFTER it becomes the default behavior. |
# Conflicts: # src/azure-cli/azure/cli/command_modules/role/_help.py # src/azure-cli/azure/cli/command_modules/role/custom.py
yonzhan
left a comment
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.
LGTM
Description
az ad sp create-for-rbaccreates a Contributor role assignment at subscription scope if--skip-assignmentor--roleis not provided. This is a dangerous behavior and contradicts the principle of least privilege.This PR adds the warning to help message and command execution that:
Testing Guide
See email: