Skip to content

Commit a08c661

Browse files
authored
Merge pull request #883 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents c632ac6 + 5e67b3f commit a08c661

20 files changed

Lines changed: 71 additions & 18 deletions

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ function New-CIPPAPIConfig {
7575

7676
Write-Information 'Creating password'
7777
$Step = 'Creating Application Password'
78-
$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`"}}" -maxRetries 3
78+
$AppManagementPolicy = New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/policies/defaultAppManagementPolicy" -AsApp $true -NoAuthCheck $true
79+
$PasswordExpirationPolicy = $AppManagementPolicy.applicationRestrictions.passwordcredentials |
80+
Where-Object { $_.restrictionType -eq 'passwordLifetime' }
81+
if (-not ($PasswordExpirationPolicy.state -eq 'disabled' -or $null -eq $PasswordExpirationPolicy.state)) {
82+
$TimeToExpiration = [System.Xml.XmlConvert]::ToTimeSpan($PasswordExpirationPolicy.maxLifetime)
83+
$ExpirationDate = (Get-Date).AddDays($TimeToExpiration.Days).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.fffZ')
84+
$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`",`"endDateTime`":`"$ExpirationDate`"}}" -maxRetries 3
85+
} else {
86+
$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`"}}" -maxRetries 3
87+
}
7988
Write-Information 'Adding App URL'
8089
$Step = 'Adding Application Identifier URI'
8190
$APIIdUrl = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/applications/$($APIApp.id)" -AsApp $true -NoAuthCheck $true -type PATCH -body "{`"identifierUris`":[`"api://$($APIApp.appId)`"]}" -maxRetries 3

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecTimeSettings.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ function Invoke-ExecTimeSettings {
5757
Write-Information "Updating function app time settings: Timezone=$Timezone, BusinessHoursStart=$BusinessHoursStart, BusinessHoursEnd=$BusinessHoursEnd"
5858

5959
# Build app settings hashtable
60+
# Linux Consumption (Dynamic SKU) does not support WEBSITE_TIME_ZONE
61+
$IsLinuxConsumption = $IsLinux -and $env:WEBSITE_SKU -ne 'FlexConsumption'
62+
63+
if ($IsLinuxConsumption) {
64+
Write-Information 'Skipping WEBSITE_TIME_ZONE — not supported on Linux Consumption plans'
65+
$Results = @{
66+
Results = 'Timezone setting is not supported on Linux Consumption function apps. No changes were made.'
67+
SKU = $env:WEBSITE_SKU
68+
}
69+
return ([HttpResponseContext]@{
70+
StatusCode = [httpstatusCode]::OK
71+
Body = $Results
72+
})
73+
}
74+
6075
$AppSettings = @{
6176
'WEBSITE_TIME_ZONE' = $Timezone
6277
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecSAMSetup.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ function Invoke-ExecSAMSetup {
1111
[CmdletBinding()]
1212
param($Request, $TriggerMetadata)
1313

14+
return ([HttpResponseContext]@{
15+
StatusCode = [HttpStatusCode]::OK
16+
Body = @{ message = 'This endpoint is no longer used. Please use the CreateSAMApp endpoint instead.' }
17+
})
1418

1519
if ($Request.Query.error) {
1620
Add-Type -AssemblyName System.Web

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Invoke-ListDBCache.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ function Invoke-ListDBCache {
3636
})
3737
}
3838

39+
if ($Type -eq '_availableTypes') {
40+
$Types = Get-CIPPDbItem -CountsOnly -TenantFilter $Tenant | Select-Object -ExpandProperty RowKey
41+
$Types = $Types | ForEach-Object { $_ -replace '-Count$', '' } | Sort-Object
42+
return ([HttpResponseContext]@{
43+
StatusCode = [HttpStatusCode]::OK
44+
Body = @{ Results = @($Types) }
45+
})
46+
}
47+
3948
if ($Tenant) {
4049
$Results = New-CIPPDbRequest -TenantFilter $Tenant -Type $Type
4150
}

Modules/CIPPCore/Public/Set-CIPPDBCacheAdminConsentRequestPolicy.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function Set-CIPPDBCacheAdminConsentRequestPolicy {
2020
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Caching admin consent request policy' -sev Debug
2121
$ConsentPolicy = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/adminConsentRequestPolicy' -tenantid $TenantFilter
2222
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AdminConsentRequestPolicy' -Data @($ConsentPolicy)
23+
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AdminConsentRequestPolicy' -Data @($ConsentPolicy) -Count
2324
$ConsentPolicy = $null
2425

2526
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Cached admin consent request policy successfully' -sev Debug

Modules/CIPPCore/Public/Set-CIPPDBCacheAuthenticationFlowsPolicy.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ function Set-CIPPDBCacheAuthenticationFlowsPolicy {
2323

2424
if ($AuthFlowPolicy) {
2525
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AuthenticationFlowsPolicy' -Data @($AuthFlowPolicy)
26+
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AuthenticationFlowsPolicy' -Data @($AuthFlowPolicy) -Count
2627
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Cached authentication flows policy successfully' -sev Debug
2728
}
2829

2930
} catch {
30-
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message "Failed to cache authentication flows policy: $($_.Exception.Message)" -sev Warning -LogData (Get-CippException -Exception $_)
31+
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message "Failed to cache authentication flows policy: $($_.Exception.Message)" -sev Warning -LogData (Get-CippException -Exception $_)
3132
}
3233
}

Modules/CIPPCore/Public/Set-CIPPDBCacheAuthenticationMethodsPolicy.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function Set-CIPPDBCacheAuthenticationMethodsPolicy {
2020
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Caching authentication methods policy' -sev Debug
2121
$AuthMethodsPolicy = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy' -tenantid $TenantFilter
2222
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AuthenticationMethodsPolicy' -Data @($AuthMethodsPolicy)
23+
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AuthenticationMethodsPolicy' -Data @($AuthMethodsPolicy) -Count
2324
$AuthMethodsPolicy = $null
2425

2526
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Cached authentication methods policy successfully' -sev Debug

Modules/CIPPCore/Public/Set-CIPPDBCacheAuthorizationPolicy.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function Set-CIPPDBCacheAuthorizationPolicy {
2020
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Caching authorization policy' -sev Debug
2121
$AuthPolicy = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/authorizationPolicy' -tenantid $TenantFilter
2222
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AuthorizationPolicy' -Data @($AuthPolicy)
23+
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'AuthorizationPolicy' -Data @($AuthPolicy) -Count
2324
$AuthPolicy = $null
2425

2526
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Cached authorization policy successfully' -sev Debug

Modules/CIPPCore/Public/Set-CIPPDBCacheB2BManagementPolicy.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function Set-CIPPDBCacheB2BManagementPolicy {
2424

2525
if ($B2BManagementPolicy) {
2626
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'B2BManagementPolicy' -Data @($B2BManagementPolicy)
27+
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'B2BManagementPolicy' -Data @($B2BManagementPolicy) -Count
2728
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Cached B2B management policy successfully' -sev Debug
2829
} else {
2930
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'No B2B management policy found' -sev Debug

Modules/CIPPCore/Public/Set-CIPPDBCacheCrossTenantAccessPolicy.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function Set-CIPPDBCacheCrossTenantAccessPolicy {
2020
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Caching cross-tenant access policy' -sev Debug
2121
$CrossTenantPolicy = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/crossTenantAccessPolicy/default' -tenantid $TenantFilter
2222
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'CrossTenantAccessPolicy' -Data @($CrossTenantPolicy)
23+
Add-CIPPDbItem -TenantFilter $TenantFilter -Type 'CrossTenantAccessPolicy' -Data @($CrossTenantPolicy) -Count
2324
$CrossTenantPolicy = $null
2425
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message 'Cached cross-tenant access policy successfully' -sev Debug
2526

0 commit comments

Comments
 (0)