Skip to content

Commit 4c42f72

Browse files
authored
Merge pull request #47 from KelvinTegelaar/master
[pull] master from KelvinTegelaar:master
2 parents cc1e5b3 + 3d835b5 commit 4c42f72

3 files changed

Lines changed: 7 additions & 22 deletions

File tree

Modules/CIPPHTTP/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecPermissionRepair.ps1

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
function Invoke-ExecPermissionRepair {
22
<#
33
.SYNOPSIS
4-
Reconciles the CIPP-SAM permissions and re-applies them to the partner service principal.
4+
This endpoint will update the CIPP-SAM app permissions.
55
.DESCRIPTION
6-
Reconciles the saved additional-permission set (Update-CippSamPermissions), then refreshes the
7-
grants on the CIPP-SAM service principal in the PARTNER tenant so the current effective set
8-
(manifest + extras) is consented. This never writes the app registration's requiredResourceAccess;
9-
permissions are applied as service-principal grants, the same way the routine refresh does.
10-
Client tenants pick up the same effective set through their own permission refresh.
6+
Merges new permissions from the SAM manifest into the AppPermissions entry for CIPP-SAM.
117
.FUNCTIONALITY
128
Entrypoint
139
.ROLE
@@ -18,19 +14,8 @@ function Invoke-ExecPermissionRepair {
1814

1915
try {
2016
$User = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Request.Headers.'x-ms-client-principal')) | ConvertFrom-Json
21-
$UpdatedBy = $User.UserDetails ?? 'CIPP-API'
22-
23-
# 1) Reconcile the saved extras table (no app-registration write).
24-
$TableResult = Update-CippSamPermissions -UpdatedBy $UpdatedBy
25-
26-
# 2) Refresh the grants on the partner CIPP-SAM service principal so the effective set
27-
# (manifest + extras, read from the table) is actually consented on the SP.
28-
$AppResults = Add-CIPPApplicationPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $env:ApplicationID -TenantFilter $env:TenantID
29-
$DelegatedResults = Add-CIPPDelegatedPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $env:ApplicationID -TenantFilter $env:TenantID
30-
31-
$Results = @($TableResult) + @($AppResults) + @($DelegatedResults) | Where-Object { $_ }
32-
Write-LogMessage -Headers $Request.Headers -API 'ExecPermissionRepair' -message "CIPP-SAM permissions repaired by $UpdatedBy" -Sev 'Info' -LogData @{ Results = @($Results) }
33-
$Body = @{'Results' = ($Results -join [Environment]::NewLine) }
17+
$Result = Update-CippSamPermissions -UpdatedBy ($User.UserDetails ?? 'CIPP-API')
18+
$Body = @{'Results' = $Result }
3419
} catch {
3520
$Body = @{
3621
'Results' = "$($_.Exception.Message) - at line $($_.InvocationInfo.ScriptLineNumber)"

host.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"distributedTracingEnabled": false,
1717
"version": "None"
1818
},
19-
"defaultVersion": "10.5.6",
19+
"defaultVersion": "10.5.7",
2020
"versionMatchStrategy": "Strict",
2121
"versionFailureStrategy": "Fail"
2222
}
2323
}
24-
}
24+
}

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.5.6
1+
10.5.7

0 commit comments

Comments
 (0)