Hi, after upgrade to Zabbix 7.2 our Powershell scripts stopped working, because we were using "auth" parameter for all requests (API methods) and that parameter was removed.
I can successfully get auth token and then I use
Code:
$header = @{ "Authorization" = "Bearer $authToken"}
$response = Invoke-RestMethod $url -ContentType "application/json-rpc; charset=utf-8" -Method Post -Headers $header -Credential $credentials -Body ([System.Text.Encoding]::UTF8.GetBytes($jsonRequest))
Code:
$response.error
Code:
code=-32602; message=Invalid params.; data=Not authorized.
Code:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
To my surprise I get these HTTP headers
Code:
HTTP_AUTHORIZATION = Negotiate YIIJAwYGKwYBBQUCoIII9zCCCPOg <shortened> HTTP_USER_AGENT = Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.14393.7693 HTTP_HOST = zabbix.mydomain.tld
If I run just
Code:
$response = Invoke-RestMethod $url -ContentType "application/json-rpc; charset=utf-8" -Method Post -Headers $header -Body ([System.Text.Encoding]::UTF8.GetBytes($jsonRequest))
Code:
-Credential $credentials
Code:
Invoke-RestMethod : 401 Unauthorized Unauthorized This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
So my question is, how do I authenticate to Zabbix from that Powershell script ?
FYI we are using HTTP authetication to Zabbix UI, hence the Negotatiate authentication. Would some URL rewrite work (changing the Authorization header on Apache) ?
But that was intentionally set up already long time ago, not related to any of this topic..
Comment