Add header auth to n8n webhook call
Introduce header-based authentication for the n8n webhook request by adding $AuthHeaderName and $AuthHeaderValue, constructing a $Headers hashtable, and passing it to Invoke-RestMethod via the -Headers parameter. Keeps the existing payload (status, service, output) and log retrieval; webhook URL is unchanged.
This commit is contained in:
@@ -88,13 +88,24 @@ Write-Host "All requested updates finished." -ForegroundColor Cyan
|
||||
Stop-Transcript
|
||||
$LogContent = Get-Content "$env:TEMP\docker_update_log.txt" -Raw
|
||||
|
||||
# Send to n8n (Replace the URL with your actual n8n Webhook URL)
|
||||
# Send to n8n
|
||||
$WebhookUrl = "https://n8n.mohandl3g.ly/webhook/dockerupdater"
|
||||
|
||||
# --- SECURITY CONFIGURATION ---
|
||||
$AuthHeaderName = "MohandL3G-Auth"
|
||||
$AuthHeaderValue = "Ms@199903"
|
||||
# ------------------------------
|
||||
|
||||
$Headers = @{
|
||||
$AuthHeaderName = $AuthHeaderValue
|
||||
}
|
||||
|
||||
$Body = @{
|
||||
status = "complete"
|
||||
service = "DockerUpdater"
|
||||
output = $LogContent
|
||||
}
|
||||
|
||||
Invoke-RestMethod -Uri $WebhookUrl -Method Post -Body ($Body | ConvertTo-Json) -ContentType "application/json"
|
||||
# Added -Headers parameter here
|
||||
Invoke-RestMethod -Uri $WebhookUrl -Method Post -Body ($Body | ConvertTo-Json) -ContentType "application/json" -Headers $Headers
|
||||
# ---------------------
|
||||
Reference in New Issue
Block a user