如何将Ejabberd或MongooseIM与Node.js(或Django)连接 [英] How to connect Ejabberd or MongooseIM with Node.js (or Django)

查看:94
本文介绍了如何将Ejabberd或MongooseIM与Node.js(或Django)连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用node.js(或Django)和Ejabberd或MongooseIM为聊天应用程序开发后端服务器。并在应具有推送通知的React Native应用上使用此API。

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.

这个想法是要管理用户个人资料和元数据以及身份验证(OAuth 2.0-社交登录)通过我自己的服务器,然后将聊天内容管理到Ejabberd或MongooseIM服务器。

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.

问题在于如何在服务器之间建立连接。我想通过我的服务器登录,并且不让用户知道现有的Ejabberd或MongooseIM服务器。

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?

推荐答案


问题在于如何建立服务器之间的连接。我
希望通过我的服务器登录,并且不让用户知道现有的
Ejabberd服务器。

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)用户通过App Server REST API登录并获得一些会话令牌或类似的东西以及 user_id

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

2),则该用户使用此user_id为ejabberd建立一个JID,例如 @ yourejabberdserver.com

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

3),然后该用户使用此JID和会话令牌作为密码并连接到Ejabberd。

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

4)在这种情况下,Ejabberd会验证会话令牌(它会进入您的App Server DB并进行验证,或者如果您使用JWT令牌,那么它只会对其进行验证)。在Ejabberd中,您可以通过实施外部脚本auth来实现:

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

此方法使您无需进行第二个帐户注册(在Ejabberd侧),因此您在两个应用程序(服务器应用程序和Ejabberd中使用相同的用户凭据) )

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

这篇关于如何将Ejabberd或MongooseIM与Node.js(或Django)连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆