简体   繁体   中英

how to authenticate users with django ejabberd bridge

I am trying to integrate ejabberd with django authentication. I am following instructions on: https://github.com/ffalcinelli/django-ejabberd-bridge

I have followed every step.

I have defined the path of the script for authentication

{auth_method, external}.
{extauth_program, "script.sh"}. ( I have defined full path here )

Script file's content is :

#!/bin/bash
source <path>/env/bin/activate
python <path>/manage.py ejabberd_auth $@

My Problem is that I want ejjaberd to maintain the state of every user ( online , offline , away etc ). I think that whenever a user will login ( or logout ), that data needs to be sent to ejjaberd server. I tried to login and logout, but these users are not registering at ejabberd ( localhost:5280/admin )

I have tried this command from console :

python manage.py ejabberd_auth $@

It should ask me username and password. In the log file there is only one log :

2015-08-03 08:11:05,791 [DEBUG] ejabberd_bridge.management.commands.ejabberd_auth: Starting serving authentication requests for eJabberd

How can I send the user data to ejabberd?

You are expecting too much feature from that authentication module.

django-ejabberd-bridge purpose is to let ejabberd check authentication against Django authentication middleware, as described in project README:

Right now it just allows the ejabberd service to perform authentication against Django's authentication middleware.

This has nothing to do with changing presence for example. That bridge will be use in that worklow:

  1. a user want to log in ejabberd using XMPP client
  2. ejabberd use external auth, thus your script for Django bridge to check if user and credentials are valid.
  3. ejabberd use the result of the script to either accept or reject the user authentication request.

That's it. Presence and user state is still managed as usual with XMPP. While XMPP session is open, user will be seen as online. When XMPP client disconnect, user will be seen as offline by ejabberd, etc.

The user database is not duplicated. It is kept in the backend service. That's also the reason why user cannot be listed from the web interface: ejabberd does not handle them.

If you want only the presence of the user state, the django-ejabberd-bridge can manage it. you can see the online users in the web admin interface http://localhost:5280/admin/server/localhost/online-users/ . But in your point of registering the user, the django-ejabberd-bridge doesn't do that. If you want to register the user from django to XMPP, then you should query it with the javascript libraries like converse.js , strophe.js etc.

I haven't tried registering the user using converse.js . Strophe provide the plugin called strophe.register.js for registering the users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM