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

parameter /user is deprecated #4

Open
ghormoon opened this issue Sep 15, 2022 · 7 comments
Open

parameter /user is deprecated #4

ghormoon opened this issue Sep 15, 2022 · 7 comments

Comments

@ghormoon
Copy link
Contributor

New versions of zabbix (at least in my case of 6.0) do not accept user parameter in login, it's now username

@YanChii
Copy link

YanChii commented Sep 17, 2022

Hi @ghormoon

Thank you for reporting this. Is it the only change you've hit with new Zabbix version?

In case you already have a fix, you can consider a pull request. Contributions are very welcome.

Cheers

Jan

@ghormoon
Copy link
Contributor Author

my temporary fix is to change 'user' to 'username' here,

obj = self.json_obj('user.login', params={'user': user, 'password': password}, auth=False)

but i don't know which version started that change (i'm on 6.0.x) so i didn't do any handling for older ones

@sharewax
Copy link

https://www.zabbix.com/documentation/5.4/en/manual/api/changes_5.2_-_5.4
https://support.zabbix.com/browse/ZBXNEXT-6474
https://support.zabbix.com/browse/ZBXNEXT-6148
it was changed since 5.2 version.

@ghormoon
Copy link
Contributor Author

ghormoon commented Oct 5, 2022

it was changed in 5.4 based on that docs. Here is a patch, i didn't want to fork for such simple change, you can put it in file and git am file
do a quick test please, i'm running another fork, but i thought i should respond here too :)

From 22bd0a695259e1f7d385ce868d13d0df3bcff348 Mon Sep 17 00:00:00 2001
From: "[email protected]" <ghormoon@localhost>
Date: Wed, 5 Oct 2022 23:38:59 +0200
Subject: [PATCH] fix login for zabbix >=5.4

---
 zabbix_api.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/zabbix_api.py b/zabbix_api.py
index d8dd8f7..bc6bada 100644
--- a/zabbix_api.py
+++ b/zabbix_api.py
@@ -327,7 +327,10 @@ class ZabbixAPI(object):
         # Don't print the raw password
         hashed_pw_string = 'md5(%s)' % md5(password.encode('utf-8')).hexdigest()
         self.debug('Trying to login with %r:%r', user, hashed_pw_string)
-        obj = self.json_obj('user.login', params={'user': user, 'password': password}, auth=False)
+        if self.api_version() >= '5.4':
+            obj = self.json_obj('user.login', params={'username': user, 'password': password}, auth=False)
+        else:
+            obj = self.json_obj('user.login', params={'user': user, 'password': password}, auth=False)
         self.__auth = self.do_request(obj)
 
     def relogin(self):
-- 
2.35.1

@YanChii
Copy link

YanChii commented Oct 6, 2022

Thanks @ghormoon for the patch. I'll test and integrate it.
Jan

@ghormoon
Copy link
Contributor Author

ghormoon commented Nov 6, 2022

I've done one more edit, as on the other fork they didn't like string comparison and they have a point, so i changed it to packaging.version.parse. see PR #5

@YanChii
Copy link

YanChii commented Nov 7, 2022

Thank you @ghormoon

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

No branches or pull requests

3 participants