Fix Graph scope in SP provisioning script (#414)#415
Open
biswapm wants to merge 1 commit into
Open
Conversation
New-MgServicePrincipal requires Application.ReadWrite.All, not AppRoleAssignment.ReadWrite.All. The script never calls any app-role- assignment APIs, so requesting that scope was both insufficient (caused 403 Authorization_RequestDenied when creating V2 per-server SPs) and unnecessary over-scope. Replace with the correct least-privilege scope and update the matching 403 error hint so it no longer points users at a permission that wouldn't fix their problem.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the Microsoft Graph delegated scope requested by the service principal provisioning PowerShell script so it can successfully create missing per-server (V2) service principals, and updates the related 403 guidance to match the corrected permission.
Changes:
- Update
Connect-MgGraphto requestApplication.ReadWrite.All(instead ofAppRoleAssignment.ReadWrite.All) to align with the script’s actual use ofGet-MgServicePrincipal/New-MgServicePrincipal. - Update the “Required Permissions” hint in the insufficient-privileges error message to reference
Application.ReadWrite.All.
sellakumaran
approved these changes
May 14, 2026
gwharris7
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AppRoleAssignment.ReadWrite.AllwithApplication.ReadWrite.AllinConnect-MgGraph— the script only callsGet-MgServicePrincipal/New-MgServicePrincipal, both of which requireApplication.*, notAppRoleAssignment.*.Fixes #414. With the previous scope, V2 per-server SPs that didn't already exist failed with
Authorization_RequestDenied (403). The V1 ATG SP is typically pre-existing so the bug was masked there.Chose replace over append (the reporter's suggested diff) for least-privilege: the script never exercises
AppRoleAssignment.*APIs, so admins shouldn't be asked to consent to that permission.Test plan
V1mode against a tenant where the V1 SP already exists (verify no regression on the pre-existing-SP path).V2mode against a tenant missing one or more V2 per-server SPs (verify creation succeeds where it previously hit 403).Allmode end-to-end.Application.ReadWrite.All.Application.ReadWrite.All.