Icinga/icingaweb2

IcingaWeb2 API requests do not work with php8.1.25 / php8.2.13

moreamazingnick opened this issue · 6 comments

Describe the bug

All icingaweb2 api requests that require authentification return 401 Unauthorized with php 8.1.25 / 8.2.13. As soon as i switch back to 7.4 everything works fine.

I came across that issue trying out the $isApified = True and I got the unauthorized message again and again not knowing what went wrong. My own controller works fine with php 7.4 as well.

There is no entry in the application log / php log or any other log.

Best Regards Nicolas

To Reproduce

Use php 8.1.2.5 or 8.2.13 fpm

hosturl = "https://myicinga/icingaweb2/director/host?name=myicicngahost'
print(hosturl)
page = requests.get(hosturl, verify=False,
                     headers={'Accept': 'application/json'},
                     auth=("myuser", "mypassword"))
print(page.status_code)
print(page.content)
exit()

the http status code of the request above is 200 for php7.4 and 401 for php8.1/8.2

Your Environment

  • Icinga Web 2 version and modules (System - About): 2.12.1
  • Web browser used: Chrome
  • PHP version used (php --version): 7.4 / 8.1.2.5 / 8.2.13
  • Server operating system and version: Ubuntu 20.04

If your user isn't an admin, please show us its assigned role(s)

user is admin
for testing I created 2 vhosts one using php8 and the other one using php7 like
php8.icinga.local
php7.icinga.local
same credentials in the script. everything works fine. except the api request in php8

Then I cannot reproduce this. Is your user from the database? Then please change the password. The password hash algorithm or something else might interfere.

I changed the password, no change:

https://php7.icinga.local/icingaweb2/icingadb/service/acknowledge?name=AGENT%20PSH%20check_nla&host.name=LAPTOP-C30TH6JK
422
b'{"status":"fail","data":{"comment":[],"persistent":[],"notify":[],"sticky":[],"expire":[]}}'

https://php8.icinga.local/icingaweb2/icingadb/service/acknowledge?name=AGENT%20PSH%20check_nla&host.name=LAPTOP-C30TH6JK
401
b''

So, this must have something to do with how authentication is done. Have you turned on debug logging? This should give at least a clue what the difference is.

I might have wasted your time and I'm really sorry.
I disabled all php* and enabled php8.2 which did the trick

a2dismod php*
a2enmod php8.2