0

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?

Stefano Mtangoo
  • 6,017
  • 6
  • 47
  • 93

2 Answers2

1

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
Badlop
  • 3,840
  • 1
  • 8
  • 9
  • Well, I think I complicated matters as they should be. However, I'm confused as to how ejabberd knows for example my roster. In my (may be wrong) thoughts I expected it to use for example user ID and to create its internal relations. I was dead wrong, lol! Thanks for your answer. I actually do not need to do anything with my current set! – Stefano Mtangoo Jan 11 '22 at 15:46
  • 1
    Right, it's rather simple, that's why I thought you had some mistery hidden. BTW; if you use mnesia internal database, you can inspect tables contents in the ejabberd webadmin -> Nodes -> your node -> Database. – Badlop Jan 11 '22 at 21:24
  • I read somewhere in logs that Mnesia is limited to capacity, so I opted SQL and I can inspect tables via SQL DB Manager – Stefano Mtangoo Jan 12 '22 at 12:12
0

I have a working ejabberd installation authenticating login with custom script.

What authentication method are you using, from the ones documented in https://docs.ejabberd.im/admin/configuration/authentication/ ?

Are you using "external"?

As of now I have users duplicated in ejabberd user table and custom user table.

How can that be? If you are using "external" authentication script, the account credentials (username+password) are not stored in ejabberd.

What is "ejabberd user table"? What is "custom user table"?

There is something misterious in your setup, that make impossible to help you.

Badlop
  • 3,840
  • 1
  • 8
  • 9
  • `Are you using "external"?` Yes, am using external script authentication (thanks for helping in the other question) – Stefano Mtangoo Jan 11 '22 at 09:30
  • The ejabberd table was created from provided sql script so It is there by default, that is what I callled "ejabberd user table". The "custom user table" is the actual table that holds my users when they register to the application. – Stefano Mtangoo Jan 11 '22 at 09:33
  • I have updated the question, please check if it is still not clear – Stefano Mtangoo Jan 11 '22 at 09:44