Nagios REST API throws HTP 200 with invalid api key
Posted: Mon Jan 20, 2020 9:16 am
Hello,
We have an Ansible playbook using he Nagios REST API and noticed that even when the API key is invalid, Nagios still gives a 200 (ok). This is not really what we were expecting. Instead a 401 or 403 should be returned?
Grtz
We have an Ansible playbook using he Nagios REST API and noticed that even when the API key is invalid, Nagios still gives a 200 (ok). This is not really what we were expecting. Instead a 401 or 403 should be returned?
Code: Select all
{
"content_length": "28",
"cookies": {},
"connection": "close",
"x_powered_by": "PHP/7.2.25",
"elapsed": 0,
"invocation": {
"module_args": {
"directory_mode": null,
"force": false,
"remote_src": null,
"status_code": [
"200"
],
"body_format": "raw",
"owner": null,
"follow": false,
"client_key": null,
"group": null,
"use_proxy": true,
"unix_socket": null,
"unsafe_writes": null,
"serole": null,
"content": null,
"setype": null,
"follow_redirects": "safe",
"return_content": true,
"method": "POST",
"body": "host_name=srvcentos8ks&service_description=SVC_Automatic&use=dig_srv_lin_svc_automatic_prio2&check_period=xi_timeperiod_24x7&contacts=%2Bnagiosadmin&contact_groups=%2Bcg_dummy¬ification_period=xi_timeperiod_24x7&force=1",
"url_username": null,
"url_password": null,
"dest": null,
"selevel": null,
"force_basic_auth": false,
"removes": null,
"http_agent": "ansible-httpget",
"regexp": null,
"src": null,
"url": "https://nagios/nagiosxi/api/v1/config/service?apikey=",
"backup": null,
"seuser": null,
"client_cert": null,
"creates": null,
"headers": {},
"delimiter": null,
"mode": null,
"timeout": 120,
"attributes": null,
"validate_certs": true
}
},
"content_type": "application/json",
"date": "Fri, 17 Jan 2020 16:17:13 GMT",
"_ansible_no_log": false,
"access_control_allow_methods": "*",
"url": "https://nagios/nagiosxi/api/v1/config/service?apikey=",
"changed": false,
"json": {
"error": "Invalid API Key"
},
"server": "Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.25",
"content": "{\"error\":\"Invalid API Key\"}\n",
"access_control_allow_orgin": "*",
"status": 200,
"msg": "OK (28 bytes)",
"redirected": false,
"cookies_string": ""
}