Ejabberd Django外部身份验证不起作用

时间:2019-07-03 15:49:44

标签: python django python-3.x xmpp ejabberd

我正在一个需要聊天系统的Django网站上工作,因此我想实现一个针对Django后端进行身份验证的XMPP服务器。

我一直在使用不同的Ejabberd外部身份验证脚本,例如django-xmpp,django-ejabberd-bridge和可以在https://www.ejabberd.im/files/contributions/ejabberd_auth_bridge.py.txt上找到的脚本

但是它们都没有起作用。 django-xmpp提供的脚本在登录XMPP服务器时崩溃,并显示错误

An error has occurred during eJabberd external authentication: unpack requires a buffer of 2 bytes
Traceback (most recent call last):
File "/home/dcpacky/Public/plutus.live/userdashboard/management/commands/ejabberd_auth.py", line 105, in handle
data = self.from_ejabberd()
File "/home/dcpacky/Public/plutus.live/userdashboard/management/commands/ejabberd_auth.py", line 40, in from_ejabberd
(size,) = struct.unpack(">h", input_length)
struct.error: unpack requires a buffer of 2 bytes

然后身份验证脚本崩溃。使用django-ejabberd-bridge会发生相同的错误,但是由于django-xmpp是基于django-ejabberd-bridge的,因此错误源可能相同。

当我一直使用上面链接的Ejabberd文档中的实现时,会发生以下错误。

Traceback (most recent call last):
File "/home/dcpacky/Public/plutus.live/userdashboard/management/commands/ejabberd_auth.py", line 126, in handle
size = struct.unpack('>h', length)[0]
TypeError: a bytes-like object is required, not 'str'

我尝试使用诸如str(),encode(),decode()之类的功能,但仍无法使其正常工作。 Ejabberd文档中的脚本也适用于早期版本的Django,甚至适用于Python 2。我已经读过Python 2处理字节,字符串和编码的方式与现在使用Python 3有所不同,但是我对Py 2没有任何经验,也无法指出确切的问题。

可以在django-xmpp和django-ejabberd-bridge的github存储库中以及上面的链接中找到认证脚本。

https://github.com/ffalcinelli/django-ejabberd-bridge/blob/master/ejabberd_bridge/management/commands/ejabberd_auth.py

https://github.com/fpytloun/django-xmpp/blob/master/xmpp/management/commands/ejabberd_auth.py

如果需要更多信息,请随时询问。 :)

0 个答案:

没有答案