1
votes

I want to develop a backend server for a chat application using node.js (or Django) and Ejabberd or MongooseIM. And consume this API on a React Native app that should have push notifications.

The idea is to manage the user profile and metadata and also the authentication ( OAuth 2.0 - social login ) through my own server, then let the management of the chat stuff to the Ejabberd or MongooseIM server.

The problems come on how to make the connection between the servers. I want to login through my server and don't make the user aware of the existing Ejabberd or MongooseIM server.

Any idea on how can I make the connection between the servers?

1

1 Answers

1
votes

The problems come on how to make the connection between the servers. I want to login through my server and don't make the user aware of the existing Ejabberd server.

I think it's not a right way

Here is how I see it and how I implemented it in some projects:

1) a user logins via App Server REST API and obtains some session token or something like this and user_id

2) then this user uses this user_id to build a JID for ejabberd, e.g. @yourejabberdserver.com

3) then this user uses this JID and session token as a password and connect to Ejabberd.

4) Ejabberd in this case verifies the session token (it goes to your App Server DB and verify or if you use a JWT token then it just verifies it). In Ejabberd you can do it by implementing external script auth:

This approach saves you from 2nd account registration (at Ejabberd side), so you use the same user credentials in both apps (Server App & Ejabberd)