Skip to content

Commit 60aaa8c

Browse files
authored
Merge pull request #131 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 10955a5 + 5bd7b4b commit 60aaa8c

File tree

74 files changed

+194
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+194
-134
lines changed

Config/cipp-roles.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"readonly": {
3+
"include": ["*.Read"],
4+
"exclude": ["CIPP.SuperAdmin.*"]
5+
},
6+
"editor": {
7+
"include": ["*.Read", "*.ReadWrite"],
8+
"exclude": [
9+
"CIPP.SuperAdmin.*",
10+
"CIPP.Admin.*",
11+
"CIPP.AppSettings.*",
12+
"Tenant.Standards.ReadWrite"
13+
]
14+
},
15+
"admin": {
16+
"include": ["*"],
17+
"exclude": ["CIPP.SuperAdmin.*"]
18+
},
19+
"superadmin": {
20+
"include": ["*"],
21+
"exclude": []
22+
}
23+
}

Modules/CIPPCore/Public/Authentication/Get-CIPPHttpFunctions.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function Get-CIPPHttpFunctions {
99
$Results = foreach ($Function in $Functions) {
1010
$Help = Get-Help $Function
1111
if ($Help.Functionality -ne 'Entrypoint') { continue }
12+
if ($Help.Role -eq 'Public') { continue }
1213
[PSCustomObject]@{
1314
Function = $Function.Name
1415
Role = $Help.Role

Modules/CIPPCore/Public/Authentication/New-CIPPAPIConfig.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ function New-CIPPAPIConfig {
5353

5454
if ($PSCmdlet.ShouldProcess($AppName, 'Create API App')) {
5555
Write-Information 'Creating app'
56-
$APIApp = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/applications' -NoAuthCheck $true -type POST -body $CreateBody
56+
$APIApp = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/applications' -AsApp $true -NoAuthCheck $true -type POST -body $CreateBody
5757
Write-Information 'Creating password'
58-
$APIPassword = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/applications/$($APIApp.id)/addPassword" -NoAuthCheck $true -type POST -body "{`"passwordCredential`":{`"displayName`":`"Generated by API Setup`"}}"
58+
$APIPassword = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/applications/$($APIApp.id)/addPassword" -AsApp $true -NoAuthCheck $true -type POST -body "{`"passwordCredential`":{`"displayName`":`"Generated by API Setup`"}}"
5959
Write-Information 'Adding App URL'
60-
$APIIdUrl = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/applications/$($APIApp.id)" -NoAuthCheck $true -type PATCH -body "{`"identifierUris`":[`"api://$($APIApp.appId)`"]}"
60+
$APIIdUrl = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/applications/$($APIApp.id)" -AsApp $true -NoAuthCheck $true -type PATCH -body "{`"identifierUris`":[`"api://$($APIApp.appId)`"]}"
6161
Write-Information 'Adding serviceprincipal'
62-
$ServicePrincipal = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/serviceprincipals' -NoAuthCheck $true -type POST -body "{`"accountEnabled`":true,`"appId`":`"$($APIApp.appId)`",`"displayName`":`"$AppName`",`"tags`":[`"WindowsAzureActiveDirectoryIntegratedApp`",`"AppServiceIntegratedApp`"]}"
62+
$ServicePrincipal = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/serviceprincipals' -AsApp $true -NoAuthCheck $true -type POST -body "{`"accountEnabled`":true,`"appId`":`"$($APIApp.appId)`",`"displayName`":`"$AppName`",`"tags`":[`"WindowsAzureActiveDirectoryIntegratedApp`",`"AppServiceIntegratedApp`"]}"
6363
Write-LogMessage -headers $Headers -API $APINAME -tenant 'None '-message "Created CIPP-API App with name '$($APIApp.displayName)'." -Sev 'info'
6464
}
6565
}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ function Test-CIPPAccess {
1212
# Check help for role
1313
$APIRole = $Help.Role
1414

15-
$AnyTenantAllowedFunctions = @('ListTenants', 'ListUserSettings', 'ListUserPhoto', 'GetCippAlerts', 'GetVersion')
15+
if ($APIRole -eq 'Public') {
16+
return $true
17+
}
18+
19+
# Get default roles from config
20+
$CIPPCoreModuleRoot = Get-Module -Name CIPPCore | Select-Object -ExpandProperty ModuleBase
21+
$CIPPRoot = (Get-Item $CIPPCoreModuleRoot).Parent.Parent
22+
$BaseRoles = Get-Content -Path $CIPPRoot\Config\cipp-roles.json | ConvertFrom-Json
1623

1724
if ($Request.Headers.'x-ms-client-principal-idp' -eq 'aad' -and $Request.Headers.'x-ms-client-principal-name' -match '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$') {
1825
# Direct API Access
@@ -132,15 +139,15 @@ function Test-CIPPAccess {
132139
}
133140
}
134141
}
142+
135143
if (!$APIAllowed) {
136-
throw "Access to this CIPP API endpoint is not allowed, the '$($Role.Role)' custom role does not have the required permission: $APIRole"
144+
throw "Access to this CIPP API endpoint is not allowed, you do not have the required permission: $APIRole"
137145
}
138-
if (!$TenantAllowed -and $AnyTenantAllowedFunctions -notcontains $Request.Params.CIPPEndpoint) {
146+
if (!$TenantAllowed -and $Help.Functionality -notmatch 'AnyTenant') {
139147
throw 'Access to this tenant is not allowed'
140148
} else {
141149
return $true
142150
}
143-
144151
} else {
145152
# No permissions found for any roles
146153
if ($TenantList.IsPresent) {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecAddAlert.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using namespace System.Net
33
Function Invoke-ExecAddAlert {
44
<#
55
.FUNCTIONALITY
6-
Entrypoint
6+
Entrypoint,AnyTenant
77
.ROLE
88
CIPP.Alert.ReadWrite
99
#>

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecEditTemplate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using namespace System.Net
33
Function Invoke-ExecEditTemplate {
44
<#
55
.FUNCTIONALITY
6-
Entrypoint
6+
Entrypoint,AnyTenant
77
.ROLE
88
CIPP.Core.ReadWrite
99
#>

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecGeoIPLookup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using namespace System.Net
33
Function Invoke-ExecGeoIPLookup {
44
<#
55
.FUNCTIONALITY
6-
Entrypoint
6+
Entrypoint,AnyTenant
77
.ROLE
88
CIPP.Core.Read
99
#>

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecServicePrincipals.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function Invoke-ExecServicePrincipals {
22
<#
33
.FUNCTIONALITY
4-
Entrypoint
4+
Entrypoint,AnyTenant
55
.ROLE
66
CIPP.Core.ReadWrite
77
#>

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-GetCippAlerts.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using namespace System.Net
33
Function Invoke-GetCippAlerts {
44
<#
55
.FUNCTIONALITY
6-
Entrypoint
6+
Entrypoint,AnyTenant
77
.ROLE
88
CIPP.Core.Read
99
#>

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-GetVersion.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using namespace System.Net
33
Function Invoke-GetVersion {
44
<#
55
.FUNCTIONALITY
6-
Entrypoint
6+
Entrypoint,AnyTenant
77
.ROLE
88
CIPP.AppSettings.Read
99
#>

0 commit comments

Comments
 (0)