ejabberdejabberd-api

Use custom users table for eJabberd


Updated Answer

So I have a mobile app with registration and login working (with other features of course, but they are not important in this context). Now I want to add chat features to this application. I installed eJabberd, imported SQL script and enabled SQL. The resultant here is two users table, one that the app uses for registration and login, and another is one created by importing ejabberd script which ejabberdctrl registers its users by default.

Then I set up external authentication, which is using app users table (not one created by ejabberd).

Now my question is, with this setup that bypasses ejabberd users table, will the ejabberd server still work? I'm trying to think for example how will ejabberd organize account rosters when it does not know about app users table and its table is empty?

In other words, how can I tell ejabberd to use my custom app table for all users operations instead of its default table? I want to avoid having to insert data in two tables.

Old question (to preserve answers context)

I have a working ejabberd installation authenticating login with custom script. It works fine. But now am facing an issue, that's more of foreseen problem than actually encountered.

As of now I have users duplicated in ejabberd user table and custom user table. This means I will need to post data to my registration API as well ss ejabberd API. Is there a way to tell ejabberd to use certain table as users table in config? Or will it be safe if I just ignore users table and not register and user with ejabberd altogether? Will the rest of ejabberd work?


Solution

  • Regardless of what tables exist (or not) and what content they have, ejabberd will use only the one you define in auth_method, as mentioned in the Authentication documentation:

    auth_method: internal
    

    ejabberd will use the 'passwd' table in the Mnesia internal database.

    auth_method: sql
    

    ejabberd will use the 'users' table in the SQL database that you configured.

    auth_method: external
    

    ejabberd will use the extauth script.

    auth_method: [sql, external]
    

    ejabberd will first attempt to use sql. If that fails, it will use external. I don't know the details here, and found no documentation, fortunately you don't need to do this.

    In other words, how can I tell ejabberd to use my custom app table for all users operations instead of its default table?

    Now the answer is simple:

    auth_method: external