Skip to content

Commit 78392fe

Browse files
authored
Merge pull request #255 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 9cb6ec6 + d3b92b7 commit 78392fe

File tree

7 files changed

+50
-16
lines changed

7 files changed

+50
-16
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Application Approval/Invoke-ExecAppPermissionTemplate.ps1

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function Invoke-ExecAppPermissionTemplate {
22
<#
33
.FUNCTIONALITY
4-
Entrypoint
4+
Entrypoint,AnyTenant
55
.ROLE
66
Tenant.Application.ReadWrite
77
#>
@@ -12,7 +12,9 @@ function Invoke-ExecAppPermissionTemplate {
1212

1313
$User = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Request.Headers.'x-ms-client-principal')) | ConvertFrom-Json
1414

15-
switch ($Request.Query.Action) {
15+
$Action = $Request.Query.Action ?? $Request.Body.Action
16+
17+
switch ($Action) {
1618
'Save' {
1719
try {
1820
$Permissions = $Request.Body.Permissions
@@ -25,8 +27,11 @@ function Invoke-ExecAppPermissionTemplate {
2527
}
2628
$null = Add-CIPPAzDataTableEntity @Table -Entity $Entity -Force
2729
$Body = @{
28-
'Results' = 'Template Saved'
29-
'TemplateId' = $Entity.RowKey
30+
'Results' = 'Template Saved'
31+
'Metadata' = @{
32+
'TemplateName' = $Entity.TemplateName
33+
'TemplateId' = $Entity.RowKey
34+
}
3035
}
3136
Write-LogMessage -headers $Request.Headers -API 'ExecAppPermissionTemplate' -message "Permissions Saved for template: $($Request.Body.TemplateName)" -Sev 'Info' -LogData $Permissions
3237
} catch {
@@ -35,8 +40,39 @@ function Invoke-ExecAppPermissionTemplate {
3540
}
3641
}
3742
}
43+
'Delete' {
44+
try {
45+
$TemplateId = $Request.Body.TemplateId
46+
$Template = (Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'Templates' and RowKey eq '$TemplateId'")
47+
$TemplateName = $Template.TemplateName
48+
49+
if ($TemplateId) {
50+
$null = Remove-AzDataTableEntity @Table -Entity $Template -Force
51+
$Body = @{
52+
'Results' = "Successfully deleted template '$TemplateName'"
53+
}
54+
Write-LogMessage -headers $Request.Headers -API 'ExecAppPermissionTemplate' -message "Permission template deleted: $TemplateName" -Sev 'Info'
55+
} else {
56+
$Body = @{
57+
'Results' = 'No Template ID provided for deletion'
58+
}
59+
}
60+
} catch {
61+
$Body = @{
62+
'Results' = "Failed to delete template: $($_.Exception.Message)"
63+
}
64+
}
65+
}
3866
default {
39-
$Body = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'Templates'" | ForEach-Object {
67+
# Check if TemplateId is provided to filter results
68+
$filter = "PartitionKey eq 'Templates'"
69+
if ($Request.Query.TemplateId) {
70+
$templateId = $Request.Query.TemplateId
71+
$filter = "PartitionKey eq 'Templates' and RowKey eq '$templateId'"
72+
Write-LogMessage -headers $Request.Headers -API 'ExecAppPermissionTemplate' -message "Retrieved specific template: $templateId" -Sev 'Info'
73+
}
74+
75+
$Body = Get-CIPPAzDataTableEntity @Table -Filter $filter | ForEach-Object {
4076
[PSCustomObject]@{
4177
TemplateId = $_.RowKey
4278
TemplateName = $_.TemplateName

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Tenant/Invoke-ListTenants.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ function Invoke-ListTenants {
9696
if ($Request.Query.Mode -eq 'TenantList') {
9797
# add portal link properties
9898
$Body = $Body | Select-Object *, @{Name = 'portal_m365'; Expression = { "https://admin.cloud.microsoft/?delegatedOrg=$($_.initialDomainName)" } },
99-
@{Name = 'portal_exchange'; Expression = { "https://admin.cloud.microsoft/exchange/?delegatedOrg=$($_.initialDomainName)" } },
99+
@{Name = 'portal_exchange'; Expression = { "https://admin.cloud.microsoft/exchange?delegatedOrg=$($_.initialDomainName)" } },
100100
@{Name = 'portal_entra'; Expression = { "https://entra.microsoft.com/$($_.defaultDomainName)" } },
101-
@{Name = 'portal_teams'; Expression = { "https://admin.teams.microsoft.com/?delegatedOrg=$($_.initialDomainName)" } },
101+
@{Name = 'portal_teams'; Expression = { "https://admin.teams.microsoft.com?delegatedOrg=$($_.initialDomainName)" } },
102102
@{Name = 'portal_azure'; Expression = { "https://portal.azure.com/$($_.defaultDomainName)" } },
103103
@{Name = 'portal_intune'; Expression = { "https://intune.microsoft.com/$($_.defaultDomainName)" } },
104104
@{Name = 'portal_security'; Expression = { "https://security.microsoft.com/?tid=$($_.customerId)" } },

Modules/CIPPCore/Public/Entrypoints/Orchestrator Functions/Start-UpdatePermissionsOrchestrator.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Start-UpdatePermissionsOrchestrator {
1515
'displayName' = '*Partner Tenant'
1616
}
1717

18-
$TenantList = Get-Tenants -IncludeAll | Where-Object { $_.Excluded -eq $false }
18+
$TenantList = Get-Tenants -IncludeAll | Where-Object { $_.Excluded -eq $false -and $_.delegatedPrivilegeStatus -eq 'directTenant' }
1919

2020
$Tenants = [System.Collections.Generic.List[object]]::new()
2121
foreach ($Tenant in $TenantList) {

Modules/CIPPCore/Public/Get-CIPPAuthentication.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ function Get-CIPPAuthentication {
2222
#Get list of tenants that have 'directTenant' set to true
2323
$tenants = Get-Tenants -IncludeErrors | Where-Object -Property delegatedPrivilegeStatus -EQ 'directTenant'
2424
if ($tenants) {
25-
Write-Host "Found $($tenants.Count) tenants with directTenant set to true"
2625
$tenants | ForEach-Object {
2726
$secretname = $_.customerId -replace '-', '_'
2827
if ($secret.$secretname) {
2928
$name = $_.customerId
30-
Write-Host "Setting $name to $($secret.$secretname)"
31-
3229
Set-Item -Path env:$name -Value $secret.$secretname -Force
3330
}
3431
}

Modules/CIPPCore/Public/GraphHelper/Get-GraphToken.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $AppSecret, $refreshT
77
if (!$env:SetFromProfile) { $CIPPAuth = Get-CIPPAuthentication; Write-Host 'Could not get Refreshtoken from environment variable. Reloading token.' }
88
#If the $env:<$tenantid> is set, use that instead of the refreshtoken for all tenants.
99
$refreshToken = $env:RefreshToken
10+
if (!$tenantid) { $tenantid = $env:TenantID }
1011
$ClientType = Get-Tenants -IncludeErrors -TenantFilter $tenantid
1112
if ($clientType.delegatedPrivilegeStatus -eq 'directTenant') {
13+
Write-Host "Using direct tenant refresh token for $($clientType.customerId)"
1214
$ClientRefreshToken = Get-Item -Path "env:\$($clientType.customerId)" -ErrorAction SilentlyContinue
1315
$refreshToken = $ClientRefreshToken.Value
1416
}
@@ -47,7 +49,6 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $AppSecret, $refreshT
4749
}
4850
}
4951

50-
if (!$tenantid) { $tenantid = $env:TenantID }
5152

5253
$TokenKey = '{0}-{1}-{2}' -f $tenantid, $scope, $asApp
5354

Modules/CippExtensions/Public/Hudu/Invoke-HuduExtensionSync.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ function Invoke-HuduExtensionSync {
122122
$Links = @(
123123
@{
124124
Title = 'M365 Admin Portal'
125-
URL = 'https://admin.cloud.microsoft/?delegatedOrg={0}' -f $Tenant.initialDomainName
125+
URL = 'https://admin.cloud.microsoft?delegatedOrg={0}' -f $Tenant.initialDomainName
126126
Icon = 'fas fa-cogs'
127127
}
128128
@{
129129
Title = 'Exchange Admin Portal'
130-
URL = 'https://admin.cloud.microsoft/exchange/?delegatedOrg={0}' -f $Tenant.initialDomainName
130+
URL = 'https://admin.cloud.microsoft/exchange?delegatedOrg={0}' -f $Tenant.initialDomainName
131131
Icon = 'fas fa-mail-bulk'
132132
}
133133
@{

Modules/CippExtensions/Public/NinjaOne/Invoke-NinjaOneTenantSync.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ function Invoke-NinjaOneTenantSync {
15231523
$ManagementLinksData = @(
15241524
@{
15251525
Name = 'M365 Admin Portal'
1526-
Link = "https://admin.cloud.microsoft/?delegatedOrg=$($customer.defaultDomainName)"
1526+
Link = "https://admin.cloud.microsoft?delegatedOrg=$($customer.defaultDomainName)"
15271527
Icon = 'fas fa-cogs'
15281528
},
15291529
@{
@@ -1548,7 +1548,7 @@ function Invoke-NinjaOneTenantSync {
15481548
},
15491549
@{
15501550
Name = 'Teams Admin'
1551-
Link = "https://admin.teams.microsoft.com/?delegatedOrg=$($Customer.defaultDomainName)"
1551+
Link = "https://admin.teams.microsoft.com?delegatedOrg=$($Customer.defaultDomainName)"
15521552
Icon = 'fas fa-users'
15531553
},
15541554
@{

0 commit comments

Comments
 (0)