Search code examples
pythondjangoejabberd

How to authenticate ejabberd with django?


Problem Statement

I have a normal django model

Models.py

class Fan(models.Model):
    user_id = models.CharField(unique=True, max_length=250)
    ...
    ...

Question 1

How do i authenticate ejabberd JID against this user_id?

Question 2

Which xmpp client (android and web) supports external ejabberd authentication?

My Approach

As per the doc i made the following changes in,

ejabberd.yml

auth_method: external
extauth_program: "/home/niranj/Documents/entry.sh"

entry.sh

#!/bin/bash 

workon orchestrator
/usr/bin/python /home/niranj/Documents/work.py $@

work.py

import sys
print sys.argv

Please note that i have provided ejabberd permission to access the files above

I always get the following error in ejabberd.log

2016-05-18 15:13:11.202 [critical] <0.411.0>@extauth:loop:142 extauth script has exitted abruptly with reason 'normal'

Question 3

How do i solve this error? Anything wrong in this configuration?


Solution

  • I have found out the solution for question 3,

    work.py

    import sys
    
    while True:
        print sys.argv
    

    Need to make the loop as infinite loop this is the key here.

    As this is fixed my question 1 is also fixed which is obvious.