Skip to content

Commit 096abcf

Browse files
committed
fix(auth): guard sso migration by permissions
Refactors the SSO migration checks in `Test-CIPPAccess` to use explicit permission flags. This keeps the forced migration prompt limited to users who can manage app settings and skips migration lookups for users with no assigned permissions.
1 parent bd767ff commit 096abcf

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Modules/CIPPCore/Public/Authentication/Test-CIPPAccess.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,18 @@ function Test-CIPPAccess {
233233
$MeResponse['hostedFailedPayments'] = $true
234234
}
235235

236+
$CanManageAppSettings = $Permissions -contains 'CIPP.AppSettings.ReadWrite'
237+
$HasAnyPermission = ($Permissions | Measure-Object).Count -gt 0
238+
236239
# Forced SSO migration: non-dismissible prompt when migration env var is set
237-
if ($env:CIPP_SSO_MIGRATION_APPID -and $Permissions -contains 'CIPP.AppSettings.ReadWrite') {
240+
if ($env:CIPP_SSO_MIGRATION_APPID -and $CanManageAppSettings) {
238241
$MeResponse['forceSsoMigration'] = @{
239242
appId = $env:CIPP_SSO_MIGRATION_APPID
240243
status = 'pending'
241244
}
242245
}
243246

244-
if ($env:CIPPNG -ne 'true') {
247+
if ($env:CIPPNG -ne 'true' -and $HasAnyPermission) {
245248
try {
246249
$SSOTable = Get-CIPPTable -tablename 'SSOMigration'
247250
$SSOMigration = Get-CIPPAzDataTableEntity @SSOTable -Filter "PartitionKey eq 'SSO' and RowKey eq 'MigrationConfig'" -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)