Skip to content

Commit

Permalink
add ip even if action is not required so we get a corre3ct db.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Aug 11, 2023
1 parent 3c3e63f commit 77e9adb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Modules/CIPPCore/Public/Invoke-CIPPWebhookProcessing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,23 @@ function Invoke-CippWebhookProcessing {

#Check if the operation is allowed for this webhook.
if ($data.operation -notin $Operations) {
Write-Host "No need to process this operation."
Write-Host "No need to process this operation, but we're saving the IP for future"
Write-Host "Add IP and potential location to knownlocation db for this specific user"

if ($data.ClientIP) {
$IP = $data.ClientIP
if ($IP -match '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$') {
$IP = $IP -replace ':\d+$', '' # Remove the port number if present
}
$LocationInfo = @{
RowKey = [string]$ip
PartitionKey = [string]$data.UserId
Tenant = [string]$TenantFilter
CountryOrRegion = "$Country"
City = "$City"
}
$null = Add-AzDataTableEntity @LocationTable -Entity $LocationInfo -Force
}
return ""
}

Expand Down

0 comments on commit 77e9adb

Please sign in to comment.