Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
1.99k stars 570 forks source link

https/api connection via user and password with foreman-smart-proxy-plugin failed #8213

Open tbauriedel opened 3 years ago

tbauriedel commented 3 years ago

Describe the bug

When you try to enable the foreman-smart-proxy-plugin with api user and password on the foreman server, the connection via https get a bad request when connecting to /v1/events?queue=foreman&types=StateChange&types=AcknowledgementSet&types=AcknowledgementCleared&types=DowntimeTriggered&types=DowntimeRemoved

In the log you can see that the connection request arrives. The connection will be closed after about 5 to 10 seconds. More is not visible in the log.

After I tried to solve the problem, I got the following error message: Bad Request - bad value

The following curl works fine: curl -k -s -u foreman:foreman -H 'Accept: application/json' -X POST 'https://192.168.33.56:5665/v1/events?queue=foreman&types=StateChange&types=AcknowledgementSet&types=AcknowledgementCleared&types=DowntimeTriggered&types=DowntimeRemoved'

The following is the intercepted output:

POST /v1/events?queue=foreman&types=StateChange&types=AcknowledgementSet&types=AcknowledgementCleared&types=DowntimeTriggered&types=DowntimeRemoved HTTP/1.1 Host: 192.168.33.56:5665 Authorization: Basic Zm9yZW1hbjpmb3JlbWFu User-Agent: curl/7.61.1 Accept: application/json

The output of the Foreman plugin is the same. (The order in which it is sent is different from the curl. To avoid this as an error, I changed the order in the plugin so that it is sent exactly like the curl. Same problem though.)

To exclude the single variables like header, host, etc. I commented them out systematically. If one of these variables is missing, I get a decent error that variable X is missing. But as soon as I send the user and password instead of the certificates, it falls down.

This problem exists since Icinga 2 version 2.11 If you use the certificates instead of user and password the connection works.

I suspect the error on the Icinga 2 update to 2.11

To Reproduce

To reproduce the problem, you need a foreman-server with the foreman-smart-proxy-plugin. Finished Foreman servers can be started via the foreman/forklift repo using vagrant. In the ReadMe of the smart_proxy_monitoring plugin is a guide how to install and configure the plugin

Expected behavior

Normally there should be a constant connection between the foreman and Icinga

Your Environment

The Icinga 2 setup i have tried to use this is a standalone machine

dgoetz commented 3 years ago

While doing a training today I found that the icingabeat is also effected by this. I will create a reference issue there.

Al2Klimov commented 2 years ago

the connection via https get a bad request when connecting to /v1/events?queue=foreman&types=StateChange&types=AcknowledgementSet&types=AcknowledgementCleared&types=DowntimeTriggered&types=DowntimeRemoved

In the log you can see that the connection request arrives. The connection will be closed after about 5 to 10 seconds. More is not visible in the log.

After I tried to solve the problem, I got the following error message: Bad Request - bad value

The following curl works fine: curl -k -s -u foreman:foreman -H 'Accept: application/json' -X POST 'https://192.168.33.56:5665/v1/events?queue=foreman&types=StateChange&types=AcknowledgementSet&types=AcknowledgementCleared&types=DowntimeTriggered&types=DowntimeRemoved'

Please complete the first – not working – case to a full curl (which still doesn’t work) so I can diff them.

Al2Klimov commented 1 year ago

PING @tbauriedel