Skip to content

Commit a2eef25

Browse files
Merge pull request KelvinTegelaar#1858 from Zacgoose/JIT-reason
Feat: Add JIT reason to alert messages (add/remove)
2 parents 7c222e1 + 3c6f419 commit a2eef25

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecJITAdmin.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ function Invoke-ExecJITAdmin {
2525
$ConfigTable = Get-CIPPTable -TableName Config
2626
$Filter = "PartitionKey eq 'JITAdminSettings' and RowKey eq 'JITAdminSettings'"
2727
$JITAdminConfig = Get-CIPPAzDataTableEntity @ConfigTable -Filter $Filter
28-
28+
2929
if ($JITAdminConfig -and ![string]::IsNullOrWhiteSpace($JITAdminConfig.MaxDuration)) {
3030
# Calculate the duration between start and expiration
3131
$RequestedDuration = $Expiration - $Start
32-
32+
3333
# Parse the max duration from ISO 8601 format
3434
try {
3535
$MaxDurationTimeSpan = [System.Xml.XmlConvert]::ToTimeSpan($JITAdminConfig.MaxDuration)
36-
36+
3737
if ($RequestedDuration -gt $MaxDurationTimeSpan) {
3838
$RequestedDays = $RequestedDuration.TotalDays.ToString('0.00')
3939
$MaxDays = $MaxDurationTimeSpan.TotalDays.ToString('0.00')
@@ -194,6 +194,7 @@ function Invoke-ExecJITAdmin {
194194
$TaskBody = @{
195195
TenantFilter = $TenantFilter
196196
Name = "JIT Admin (enable): $Username"
197+
AlertComment = if (![string]::IsNullOrWhiteSpace($Request.Body.Reason)) { "JIT Reason: $($Request.Body.Reason)" } else { $null }
197198
Command = @{
198199
value = 'Set-CIPPUserJITAdmin'
199200
label = 'Set-CIPPUserJITAdmin'
@@ -226,6 +227,7 @@ function Invoke-ExecJITAdmin {
226227
$DisableTaskBody = [pscustomobject]@{
227228
TenantFilter = $TenantFilter
228229
Name = "JIT Admin ($($Request.Body.ExpireAction.value)): $Username"
230+
AlertComment = if (![string]::IsNullOrWhiteSpace($Request.Body.Reason)) { "JIT Reason: $($Request.Body.Reason)" } else { $null }
229231
Command = @{
230232
value = 'Set-CIPPUserJITAdmin'
231233
label = 'Set-CIPPUserJITAdmin'

0 commit comments

Comments
 (0)