Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zabbix api authentication not working in 6.4.0rc1 (and probably higher) #1544

Closed
solitprojects opened this issue Dec 21, 2022 · 27 comments
Closed

Comments

@solitprojects
Copy link

solitprojects commented Dec 21, 2022

During testing version 6.4.0rc1 of Zabbix, the json rpc authentication fails
apparently instead of 'user' you need to use 'username' as parameter name now

maybe not really a plugin bug, but unless Zabbix confirms this as a bug themselves, the authentication mechanism in your plugin should change to be able to work in newer versions of Zabbix

original parameters are not working:
error = Invalid parameter "/": unexpected parameter "user".

image

new parameters are working (change user -> username) :
image

Grafana Zabbix Grafana-Zabbix Plugin
v9.3.2 6.4.0rc1 4.2.10
@solitprojects
Copy link
Author

update: apparently the "user" parameter was deprecated in version 5.4. Support for it is dropped in 6.4, see [ZBXNEXT-8085]. Please update the API call in the plugin

@alexanderzobnin
Copy link
Collaborator

Yes, user was renamed to username.

@lfernandosg
Copy link

dear,

I'm on zabbix 6.4 b5 and grafana 9.3.2. Until version 6.4 b4 it was working but now I get the same error. I'm not finding in my debian file /usr/share/zabbix/api_jsonrpc.php that part to change the name to username.

follow my file

'json-rpc', 'application/json' => 'json-rpc', 'application/jsonrequest' => 'json-rpc' ]; $http_request = new CHttpRequest(); $content_type = $http_request->header('Content-Type'); $content_type = explode(';', $content_type); $content_type = $content_type[0]; if (!isset($allowed_content[$content_type])) { header('HTTP/1.0 412 Precondition Failed'); return; } require_once dirname(__FILE__).'/include/classes/core/APP.php'; header('Content-Type: application/json'); $data = $http_request->body(); try { APP::getInstance()->run(APP::EXEC_MODE_API); $apiClient = API::getWrapper()->getClient(); // unset wrappers so that calls between methods would be made directly to the services API::setWrapper(); $jsonRpc = new CJsonRpc($apiClient, $data); echo $jsonRpc->execute(); } catch (Exception $e) { // decode input json request to get request's id $jsonData = json_decode($data, true); $response = [ 'jsonrpc' => '2.0', 'error' => [ 'code' => 1, 'message' => $e->getMessage(), 'data' => '' ], 'id' => (isset($jsonData['id']) ? $jsonData['id'] : null) ]; echo json_encode($response); } session_write_close();

@alexanderzobnin
Copy link
Collaborator

Here's a test build (linux+windows). You can try it and see if issue is fixed

alexanderzobnin-zabbix-app.zip

@solitprojects
Copy link
Author

solitprojects commented Jan 4, 2023 via email

@lfernandosg
Copy link

Alexandre, the commands you have in the readme are the same ones we install in normally. How do I apply this build? is it by cli? which command? or is it through the web gui? which way?

Here's a test build (linux+windows). You can try it and see if issue is fixed

alexanderzobnin-zabbix-app.zip

Alexandre, the commands you have in the readme are the same ones we install in normally. How do I apply this build? is it by cli? which command? or is it through the web gui? which way?

@lfernandosg
Copy link

Alexandre, the commands you have in the readme are the same ones we install in normally. How do I apply this build? is it by cli? which command? or is it through the web gui? which way?

Here's a test build (linux+windows). You can try it and see if issue is fixed
alexanderzobnin-zabbix-app.zip

Alexandre, the commands you have in the readme are the same ones we install in normally. How do I apply this build? is it by cli? which command? or is it through the web gui? which way?

when copying the files to the /var/lib/grafana/plugins/alexanderzobnin-zabbix-app folder it deactivates the plugin and does not let it activate asking to reinstall the plugin.

@kestjones
Copy link

Here's a test build (linux+windows). You can try it and see if issue is fixed

alexanderzobnin-zabbix-app.zip
@alexanderzobnin , I uninstalled the old plugin, applied the bug fix and the problem still exists. I get the following message: Invalid params. Invalid parameter "/": unexpected parameter "user".

@byteschubser
Copy link

Here's a test build (linux+windows). You can try it and see if issue is fixed

alexanderzobnin-zabbix-app.zip

Please sign this test version.

plugin=alexanderzobnin-zabbix-app path=/var/lib/grafana/plugins/alexanderzobnin-zabbix-app/gpx_zabbix-plugin_freebsd_arm64
logger=plugin.loader t=2023-01-10T09:50:13.860210076Z level=warn msg="Skipping loading plugin due to problem with signature" pluginID=alexanderzobnin-zabbix-datasource status=modified
logger=plugin.loader t=2023-01-10T09:50:13.860429449Z level=warn msg="Skipping loading plugin due to problem with signature" pluginID=alexanderzobnin-zabbix-triggers-panel status=modified
logger=plugin.loader t=2023-01-10T09:50:13.860523876Z level=warn msg="Skipping loading plugin due to problem with signature" pluginID=alexanderzobnin-zabbix-app status=modified

@gimguang
Copy link

gimguang commented Jan 16, 2023

Although the unsigned plug-in is set in grafana.ini, it still cannot be used

[plugins]
enable_alpha = true
app_tls_skip_verify_insecure = true
# Enter a comma-separated list of plugin identifiers to identify plugins to load even if they are unsigned. Plugins with modified signatures are never loaded.
allow_loading_unsigned_plugins = alexanderzobnin-zabbix-datasource
# Enable or disable installing / uninstalling / updating plugins directly from within Grafana.
plugin_admin_enabled = true
;plugin_admin_external_manage_enabled = false

@greenaar
Copy link

Also running Zabbix 6.4b5. Unsigned option in grafana does not seem to work. Could you sign either your test build or a new release?

@byteschubser
Copy link

Thanks for the hint. The following works for me:

[plugins]
allow_loading_unsigned_plugins = alexanderzobnin-zabbix-app,alexanderzobnin-zabbix-datasource,alexanderzobnin-zabbix-triggers-panel

@kestjones
Copy link

kestjones commented Jan 17, 2023

I can't get the plugin to work. It gives the error:

level=warn msg="Skipping loading plugin due to problem with signature" pluginID=alexanderzobnin-zabbix-datasource status=modified.
Even adding the line:

[plugins]
allow_loading_unsigned_plugins = alexanderzobnin-zabbix-app,alexanderzobnin-zabbix-datasource,alexanderzobnin-zabbix-triggers-panel

According to grafana documentation plugins with modified signature cannot be loaded. Has anyone managed to resolve?

@solitprojects
Copy link
Author

solitprojects commented Jan 17, 2023

got it "solved" since this afternoon :

delete MANIFEST.txt from the plugin directory and restart

then it will load as "unsigned" plugin, if you add it to
[plugins]
allow_loading_unsigned_plugins = alexanderzobnin-zabbix-app,alexanderzobnin-zabbix-datasource,alexanderzobnin-zabbix-triggers-panel

in short: unsigned plugins can be overwritten, incorrect signed plugins, cannot
so the trick is to delete the signing key ...

@kestjones
Copy link

got it "solved" since this afternoon :

delete MANIFEST.txt from the plugin directory and restart

then it will load as "unsigned" plugin, if you add it to [plugins] allow_loading_unsigned_plugins = alexanderzobnin-zabbix-app,alexanderzobnin-zabbix-datasource,alexanderzobnin-zabbix-triggers-panel

in short: unsigned plugins can be overwritten, incorrect signed plugins, cannot so the trick is to delete the signing key ...

@solitprojects , It worked thank you very much.

@clintclil
Copy link

I can't get the plugin to work. It gives the error: Plugin disabled
grafanan

@spectroman
Copy link

field "user" is now only accepted as "username"

(not) nice, useless zabbix changes.

@clintclil
Copy link

Is it any tricky way to avoid this bug in pluggin side

@valdoltra
Copy link

I installed 4.2.10 but still getting the same problems with sending user instead of username. Any workarounds?
I have tried almost everything except compiling it from the source(which I am doing right now as I write).

As for digital signature I have no issues. I enabled unsigned plugins as per below, updated it through grafana UI from 4.2.6 to 4.2.10 and it can be used...

[plugins]
allow_loading_unsigned_plugins = alexanderzobnin-zabbix-app,alexanderzobnin-zabbix-datasource,alexanderzobnin-zabbix-triggers-panel

But it still throws the user param error.

Any suggestions?

@jdbarondo
Copy link

Hi, I also have the same problem. I have upgraded everything (Zabbix and Grafana) to their latest versions, and I still continue to get the same error:

Invalid params. Invalid parameter "/": unexpected parameter "user".

logger=plugin.alexanderzobnin-zabbix-datasource t=2023-02-21T15:10:45.300991485Z level=error msg="Zabbix API request error" error="Invalid params. Invalid parameter "/": unexpected parameter "user"."
logger=context userId=1 orgId=1 uname=admin t=2023-02-21T15:10:45.301609358Z level=error msg="Request Completed" method=POST path=/api/datasources/10/resources/zabbix-api status=500 remote_addr=X.X.X.X time_ms=60 duration=60.692836ms size=117 referer=https://grafana.test.es:3000/datasources/edit/mBeMTU0Vk handler=/api/datasources/:id/resources/*

@javier-lancharro
Copy link

Hi, and thanks for excellent integration...

I installed the last version of plugin that you has published in this thread... i solved "unsigned plugin" errors... but the error persist: "Invalid params. Invalid parameter "/": unexpected parameter "user".

Zabbix 6.4.0rc2

Can you help me please? I'm migrating from PRTG Network Monitor to Zabbix + Grafana and this error stops our migration.

Sorry for my poor english

Thx for advance

Best regards

@Xileck
Copy link

Xileck commented Mar 12, 2023

got it "solved" since this afternoon :

delete MANIFEST.txt from the plugin directory and restart

then it will load as "unsigned" plugin, if you add it to [plugins] allow_loading_unsigned_plugins = alexanderzobnin-zabbix-app,alexanderzobnin-zabbix-datasource,alexanderzobnin-zabbix-triggers-panel

in short: unsigned plugins can be overwritten, incorrect signed plugins, cannot so the trick is to delete the signing key ...

Thanks a lot mate this worked for me and thanks @alexanderzobnin for providing the test build, I was able to do these changes on my Grafana docker container and it worked!, you saved my life (Got a meeting this monday on how we are now monitoring network and servers using this awesome plugin)

@bpbp-boop
Copy link

Another option is editing api_jsonrpc.php on your zabbix servers to update the user parameter

52a53
> $data = str_replace('"user"', '"username"', $data);

@simonecerbone
Copy link

hello @bpbp-boop, where is the file ? I have docker installation
thanks

@glange84
Copy link

= str_replace('"user"', '"username"', $data);

Top man! Thanks!

@jpconfessor
Copy link

jpconfessor commented Mar 21, 2023

file is located here: /usr/share/zabbix/api_jsonrpc.php

then, I just had to include the additional line provided by bpbp-boop after $data variable:

...
header('Content-Type: application/json');
$data = $http_request->body();
$data = str_replace('"user"', '"username"', $data);

don't forget to make a makup before adding any changes! ;) hope this will be fixed in the future

@pptfz
Copy link

pptfz commented Mar 21, 2023

Thank you. That solves the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests