ejabberd中的预认证步骤
Pre-authentication steps in ejabberd
我正在做一个像 whatsapp 这样的项目,并使用 ejabberd 作为后端服务器与 Android/IOS 个客户端。我想做一些 whatsapp 之类的步骤-
1.客户端向服务器发送手机号码。
2. 服务器在 return 中向客户端发送 OTP 并启动一个计时器,比如 2 分钟。
3. 如果客户端在指定时间内将从服务器接收到的正确 OTP 发送到服务器。客户将被注册。
我需要帮助我应该在哪个 ejabberd 模块中编写上述步骤的代码。我知道,要修改 Ejabberd,我可以使用 Hooks 和 IQ 处理程序,但是一旦用户已经注册就可以使用它们。对吗?
我是否应该使用其他语言服务器,仅用于上述步骤?请帮忙。
您应该编写新的 ejabberd 模块,在特定端口上启动新的 SSL 服务器。对此进行身份验证。
如果您熟悉 ejabberd 的核心,您可以在配置的 listen
部分添加自己的模块并编写新模块作为服务器的后端(与编写 ejabberd_c2s
的 ejabberd 本身相同, ejabberd_service
,等等)。
我刚刚阅读了它的代码,我建议也阅读代码。
例如,在 ejabberd 版本 17.01 here reads config and runs a tcp server for every section of listen
key. every section has three parts Port, Module and Opts. For xmpp clients of ejabberd these are 5222, ejabberd_c2s
and Opts is other values. in here for every accepted connection it calls ejabberd_socket:start(Module, gen_tcp, Sock, Opts)
. In ejabberd_socket:start/4
here starts a process say A for receiving from socket and parsing XML and send them to another process say B and here 中从 ejabberd_c2s
启动一个进程 (B)。进程 B 从进程 A 接收 XML,并在 ejabberd 中执行所有关闭 XMPP 客户端的操作。
我认为您应该创建一个 restful 服务来执行此操作。
请考虑以下步骤:
- 客户端将手机号码发送到 restful 服务。
- restful 服务创建一个 OTP 并将其保存在 Redis 中并设置过期。
- 客户端将 OTP 发送到 restful 服务。如果 OTP 正确,服务会向客户端发送一个 jwt 令牌并将其保存在 Redis 中并设置过期。
- 客户端向 eJabberd 服务器发送 jwt 令牌,服务器使用
ejabberd_auth_jwt
模块进行身份验证。
这可能会满足您的要求。
我正在做一个像 whatsapp 这样的项目,并使用 ejabberd 作为后端服务器与 Android/IOS 个客户端。我想做一些 whatsapp 之类的步骤- 1.客户端向服务器发送手机号码。 2. 服务器在 return 中向客户端发送 OTP 并启动一个计时器,比如 2 分钟。 3. 如果客户端在指定时间内将从服务器接收到的正确 OTP 发送到服务器。客户将被注册。
我需要帮助我应该在哪个 ejabberd 模块中编写上述步骤的代码。我知道,要修改 Ejabberd,我可以使用 Hooks 和 IQ 处理程序,但是一旦用户已经注册就可以使用它们。对吗?
我是否应该使用其他语言服务器,仅用于上述步骤?请帮忙。
您应该编写新的 ejabberd 模块,在特定端口上启动新的 SSL 服务器。对此进行身份验证。
如果您熟悉 ejabberd 的核心,您可以在配置的 listen
部分添加自己的模块并编写新模块作为服务器的后端(与编写 ejabberd_c2s
的 ejabberd 本身相同, ejabberd_service
,等等)。
我刚刚阅读了它的代码,我建议也阅读代码。
例如,在 ejabberd 版本 17.01 here reads config and runs a tcp server for every section of listen
key. every section has three parts Port, Module and Opts. For xmpp clients of ejabberd these are 5222, ejabberd_c2s
and Opts is other values. in here for every accepted connection it calls ejabberd_socket:start(Module, gen_tcp, Sock, Opts)
. In ejabberd_socket:start/4
here starts a process say A for receiving from socket and parsing XML and send them to another process say B and here 中从 ejabberd_c2s
启动一个进程 (B)。进程 B 从进程 A 接收 XML,并在 ejabberd 中执行所有关闭 XMPP 客户端的操作。
我认为您应该创建一个 restful 服务来执行此操作。
请考虑以下步骤:
- 客户端将手机号码发送到 restful 服务。
- restful 服务创建一个 OTP 并将其保存在 Redis 中并设置过期。
- 客户端将 OTP 发送到 restful 服务。如果 OTP 正确,服务会向客户端发送一个 jwt 令牌并将其保存在 Redis 中并设置过期。
- 客户端向 eJabberd 服务器发送 jwt 令牌,服务器使用
ejabberd_auth_jwt
模块进行身份验证。
这可能会满足您的要求。