Ejabberd - ejabberd_auth_external:失败:103调用'check_password'时外部认证程序失败

问题描述 投票:1回答:1

我已经拥有一个带有authentication-key的用户模式,并希望通过它进行身份验证。我尝试通过sql实现身份验证,但由于我的架构的不同结构,我收到错误,所以我实现了外部身份验证方法。我的应用程序中使用的技术和操作系统是:

  • Node.js的
  • Ejabberd作为XMPP服务器
  • MySQL数据库
  • React-Native(前端)
  • 操作系统 - Ubuntu 18.04

我实现了https://docs.ejabberd.im/admin/configuration/#external-script中提到的外部身份验证配置,并以php脚本https://www.ejabberd.im/files/efiles/check_mysql.php.txt为例。但是我在error.log中收到了下面提到的错误。在ejabberd.yml中,我完成了以下配置。

...

HOST_CONFIG: “example.org.co”: auth_method:[external] extauth_program:“/ usr / local / etc / ejabberd / JabberAuth.class.php” auth_use_cache:false

...

此外,是否有任何外部auth javascript脚本?

这是error.log和ejabberd.log,如下所述

error.log中

2019-03-19 07:19:16.814 [错误] <0.524.0> @ejabberd_auth_external:失败:103为[email protected]调用'check_password'时外部认证程序失败:已断开连接

ejabberd.log

2019-03-19 07:19:16.811 [debug] <0.524.0> @ejabberd_http:init:151 S:[{[<<“api”>>],mod_http_api},{[<<“admin”>> ],ejabberd_web_admin}]

2019-03-19 07:19:16.811 [debug] <0.524.0> @ejabberd_http:process_header:307(#Port <0.13811>)http查询:'POST'<<“/ api / register”>>

2019-03-19 07:19:16.811 [debug] <0.524.0> @ejabberd_http:process:394 [<<“api”>>,<<“register”>>]匹配[<<“api”>> ]

2019-03-19 07:19:16.811 [info] <0.364.0> @ejabberd_listener:accept:238(<0.524.0>)接受连接:: ffff:ip - > :: ffff:ip

2019-03-19 07:19:16.814 [info] <0.524.0> @mod_http_api:log:548 API调用寄存器[{<<“user”>>,<<“test”>>},{<<“主持人“>>,<<”example.org.co“>>},{<<”密码“>>,<<”测试“>>}]来自:: ffff:ip

2019-03-19 07:19:16.814 [错误] <0.524.0> @ejabberd_auth_external:失败:103为[email protected]调用'check_password'时外部认证程序失败:已断开连接

2019-03-19 07:19:16.814 [debug] <0.524.0> @mod_http_api:extract_auth:171无效的身份验证数据:{error,invalid_auth}

任何有关此主题的帮助将不胜感激。

xmpp ejabberd ejabberd-module ejabberd-auth
1个回答
3
投票

1)关于auth_method的配置看起来不错。

2)这是我使用和升级的python脚本,为ejabberd进行外部身份验证。

#!/usr/bin/python

import sys
from struct import *
import os

def openAuth(args):
    (user, server, password) = args
    # Implement your interactions with your service / database
    # Return True or False
    return True

def openIsuser(args):
    (user, server) = args
    # Implement your interactions with your service / database
    # Return True or False
    return True


def loop():
    switcher = {
        "auth": openAuth,
        "isuser": openIsuser,
        "setpass": lambda(none): True,
        "tryregister": lambda(none): False,
        "removeuser": lambda(none): False,
        "removeuser3": lambda(none): False,
    }

    data = from_ejabberd()
    to_ejabberd(switcher.get(data[0], lambda(none): False)(data[1:]))
    loop()

def from_ejabberd():
    input_length = sys.stdin.read(2)
    (size,) = unpack('>h', input_length)
    return sys.stdin.read(size).split(':')

def to_ejabberd(result):
    if result:
        sys.stdout.write('\x00\x02\x00\x01')
    else:
        sys.stdout.write('\x00\x02\x00\x00')
    sys.stdout.flush()

if __name__ == "__main__":
    try:
        loop()
    except error:
        pass

我没有创建与Ejabberd from_ejabberd()to_ejabberd()的沟通,遗憾的是无法找回来源。

© www.soinside.com 2019 - 2024. All rights reserved.