[Role] az ad sp create-for-rbac: Deprecate creating Contributor role assignment by default#16081
[Role] az ad sp create-for-rbac: Deprecate creating Contributor role assignment by default#16081
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.
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.
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.
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
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: