Skip to content

Commit 646ed28

Browse files
committed
Enforce tenant access in application entrypoints
Filter selected tenants using Test-CIPPAccess and restrict processing to allowed tenants; add AnyTenant to functionality tags. This change updates Invoke-AddChocoApp, Invoke-AddMSPApp, Invoke-AddOfficeApp and Invoke-AddStoreApp to call Test-CIPPAccess -TenantList, compute $AllowedTenants, and only iterate over tenants present in that list (or 'AllTenants'). Minor doc updates mark these entrypoints as AnyTenant and ensure AllTenants handling remains supported.
1 parent c9afb7e commit 646ed28

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Applications/Invoke-AddChocoApp.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Function Invoke-AddChocoApp {
1+
function Invoke-AddChocoApp {
22
<#
33
.FUNCTIONALITY
4-
Entrypoint
4+
Entrypoint,AnyTenant
55
.ROLE
66
Endpoint.Application.ReadWrite
77
#>
@@ -30,7 +30,9 @@ Function Invoke-AddChocoApp {
3030
$intuneBody.detectionRules[0].path = "$($ENV:SystemDrive)\programdata\chocolatey\lib"
3131
$intuneBody.detectionRules[0].fileOrFolderName = "$($ChocoApp.PackageName)"
3232

33-
$Tenants = $Request.Body.selectedTenants.defaultDomainName
33+
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
34+
$Tenants = ($Request.Body.selectedTenants | Where-Object { $AllowedTenants -contains $_.customerId -or $AllowedTenants -contains 'AllTenants' }).defaultDomainName
35+
3436
$Results = foreach ($Tenant in $Tenants) {
3537
try {
3638
# Apply CIPP text replacement for tenant-specific variables

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Applications/Invoke-AddMSPApp.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function Invoke-AddMSPApp {
22
<#
33
.FUNCTIONALITY
4-
Entrypoint
4+
Entrypoint,AnyTenant
55
.ROLE
66
Endpoint.Application.ReadWrite
77
#>
@@ -17,7 +17,8 @@ function Invoke-AddMSPApp {
1717
$intuneBody = Get-Content "AddMSPApp\$($RMMApp.RMMName.value).app.json" | ConvertFrom-Json
1818
$intuneBody.displayName = $RMMApp.DisplayName
1919

20-
$Tenants = $Request.Body.selectedTenants
20+
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
21+
$Tenants = $Request.Body.selectedTenants | Where-Object { $AllowedTenants -contains $_.customerId -or $AllowedTenants -contains 'AllTenants' }
2122
$Results = foreach ($Tenant in $Tenants) {
2223
$InstallParams = [PSCustomObject]$RMMApp.params
2324
switch ($RMMApp.RMMName.value) {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Applications/Invoke-AddOfficeApp.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
function Invoke-AddOfficeApp {
22
<#
33
.FUNCTIONALITY
4-
Entrypoint
4+
Entrypoint,AnyTenant
55
.ROLE
66
Endpoint.Application.ReadWrite
77
#>
88
[CmdletBinding()]
99
param($Request, $TriggerMetadata)
10-
10+
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
11+
$Tenants = ($Request.Body.selectedTenants | Where-Object { $AllowedTenants -contains $_.customerId -or $AllowedTenants -contains 'AllTenants' }).defaultDomainName
1112
# Input bindings are passed in via param block.
12-
$Tenants = $Request.Body.selectedTenants.defaultDomainName
1313
$Headers = $Request.Headers
1414
$APIName = $Request.Params.CIPPEndpoint
1515
if ('AllTenants' -in $Tenants) { $Tenants = (Get-Tenants).defaultDomainName }

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Applications/Invoke-AddStoreApp.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function Invoke-AddStoreApp {
22
<#
33
.FUNCTIONALITY
4-
Entrypoint
4+
Entrypoint,AnyTenant
55
.ROLE
66
Endpoint.Application.ReadWrite
77
#>
@@ -26,8 +26,8 @@ function Invoke-AddStoreApp {
2626
'runAsAccount' = 'system'
2727
}
2828
}
29-
30-
$Tenants = $Request.body.selectedTenants.defaultDomainName
29+
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
30+
$Tenants = ($Request.Body.selectedTenants | Where-Object { $AllowedTenants -contains $_.customerId -or $AllowedTenants -contains 'AllTenants' }).defaultDomainName
3131
$Results = foreach ($Tenant in $Tenants) {
3232
try {
3333
$CompleteObject = [PSCustomObject]@{

0 commit comments

Comments
 (0)