How to connect Ejabberd or MongooseIM with Node.js (or Django)

ぐ巨炮叔叔 提交于 2019-12-24 10:22:37

问题


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:


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:

  • https://docs.ejabberd.im/admin/configuration/#authentication
  • https://docs.ejabberd.im/admin/configuration/#external-script

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



来源:https://stackoverflow.com/questions/52224543/how-to-connect-ejabberd-or-mongooseim-with-node-js-or-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!