-
Notifications
You must be signed in to change notification settings - Fork 4k
Revert default role assignment for New-AzureRmADServicePrincipal #6272
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
…te help with examples
87d1902
to
0acb1cf
Compare
* Revert change to `New-AzureRmADServicePrincipal` that gave service principals "Contributor" permissions over the current subscription if no values were provided for the `Role` or `Scope` parameters | ||
- If no values are provided for `Role` or `Scope`, the service principal is created with no permissions | ||
- If a `Role` is provided, but no `Scope`, the service principal is created with the specified `Role` permissions over the current subscription | ||
- If a `Scope` is provided, but no `Contributor`, the service principal is created with `Contributor` permissions over the specified `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.
Contributor [](start = 40, length = 11)
role
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.
How easy would it be to add a test covering each of the two parameter sets? If possible we should add before checking in. Otherwise, we should verify each scenario manually and file an issue to record the new tests this sprint.
@darshanhs90 Because that is our best guess at what the user would want in this case - since no previous versions of the cmdlet have role or scope as a parameter, there is no chance of an existing script hitting unexpected behavior in this case, as they have to provide at least '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.
LGTM. Great work, @cormacpayne.
@darshanhs90, the new behavior is meant to match the Azure CLI behavior, so the default Role is Contributor, as it is in CLI. |
@darshanhs90 @markcowl comments addressed and tests added |
…te-new-sp # Conflicts: # src/Stack.sln
ChangeLog.md
Outdated
* Revert change to `New-AzureRmADServicePrincipal` that gave service principals `Contributor` permissions over the current subscription if no values were provided for the `Role` or `Scope` parameters | ||
- If no values are provided for `Role` or `Scope`, the service principal is created with no permissions | ||
- If a `Role` is provided, but no `Scope`, the service principal is created with the specified `Role` permissions over the current subscription | ||
- If a `Scope` is provided, but no `Scope`, the service principal is created with `Contributor` permissions over the specified `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.
Role?
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.
@darshanhs90 oops, thanks. Fixed this in all occurrences.
* Revert change to `New-AzureRmADServicePrincipal` that gave service principals `Contributor` permissions over the current subscription if no values were provided for the `Role` or `Scope` parameters | ||
- If no values are provided for `Role` or `Scope`, the service principal is created with no permissions | ||
- If a `Role` is provided, but no `Scope`, the service principal is created with the specified `Role` permissions over the current subscription | ||
- If a `Scope` is provided, but no `Scope`, the service principal is created with `Contributor` permissions over the specified `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.
Role
tools/AzureRM/AzureRM.psd1
Outdated
* Revert change to `New-AzureRmADServicePrincipal` that gave service principals `Contributor` permissions over the current subscription if no values were provided for the `Role` or `Scope` parameters | ||
- If no values are provided for `Role` or `Scope`, the service principal is created with no permissions | ||
- If a `Role` is provided, but no `Scope`, the service principal is created with the specified `Role` permissions over the current subscription | ||
- If a `Scope` is provided, but no `Scope`, the service principal is created with `Contributor` permissions over the specified `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.
Role
#> | ||
function Test-NewADServicePrincipalWithReaderRole | ||
{ | ||
# Setup |
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.
can we add another test where in we dont specify any role or scope and make sure that no roleassignment change happens before and after running the command
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.
@darshanhs90 added a check in Test-NewADServicePrincipalWithoutApp
that no role assignment was created for the new service principal
Description
New-AzureRmADServicePrincipal
that gave "Contributor" permissions to the current subscription by default ifRole
andScope
parameters weren't provided. The behavior now goes back to before the 6.0.0 release where no permissions are assigned to the service principal ifRole
andScope
aren't provided, but use the values provided (or default values) if one (or both) of the parameters are provided.New-AzureRmADServicePrincipal
to reflect these changes, as well as update the descriptions for the cmdlet and the affected parametersChecklist
CONTRIBUTING.md
platyPS
module