【问题标题】:ejabberd: Saving of roster not working with external Authentication Script enabledejabberd:在启用外部身份验证脚本的情况下保存名册不起作用
【发布时间】:2016-04-01 16:39:10
【问题描述】:

我已经成功配置了一个带有 extauth 脚本 (perl) 的 ejabberd 服务器。 它工作正常,只允许来自我的 mysql 数据库的用户。

但以下功能不再起作用:名册管理、将用户添加到名册、用户授权(用于将其添加到名册) 使用内部身份验证它可以工作。两次 ejabberd 都配置为使用内部失忆数据库。

请帮我弄清楚为什么它不能在启用 extauth 的情况下工作。我必须在 extauth 脚本中编写自己的方法吗? (我真的不想要……)

【问题讨论】:

  • 日志有错误吗?
  • 不,不幸的是,没有任何东西......使用内部身份验证,它可以工作。切换到 ext_auth 时。登录工作正常,但当我将他添加到我的名册时,没有向其他用户发送身份验证请求。名册虽然被存储。两种情况下的用户完全相同。请帮忙...

标签: perl xmpp ejabberd


【解决方案1】:

所以在对我的问题进行了一些研究之后,我认为切换到外部身份验证将不支持名册管理。

我最终做的是切换回内部身份验证并使用 mod_admin_extra 使用这个 php 脚本添加用户和更新密码:

<?php

class Jabber
{
    public static function registerAndAddToSharedRoster($userId, $sessionToken)
    {
        $url = "http://localhost:5280/rest";

        $register = "register $userId jabber.YOUR_DOMAIN.com $sessionToken";
        sendRESTRequest($url, $register);

        $sharedRoster = "srg_user_add $userId jabber.YOUR_DOMAIN.com shared jabber.YOUR_DOMAIN.com";
        sendRESTRequest($url, $sharedRoster);
    }

    public static function updatePassword($userId, $newPassword)
    {
        $url = "http://localhost:5280/rest";

        $register = "change_password $userId jabber.YOUR_DOMAIN.com $newPassword";
        sendRESTRequest($url, $register);
    }
}

function sendRESTRequest ($url, $request)
{
    // Create a stream context so that we can POST the REST request to $url
    $context = stream_context_create (array ('http' => array ('method' => 'POST'
                                            ,'header' => "Host: localhost:5280\nContent-Type: text/html; charset=utf-8\nContent-Length: ".strlen($request)
                                            ,'content' => $request)));

    $result = file_get_contents($url, false, $context);

    return $result;
}

?>

希望这对某人有所帮助!

【讨论】:

    【解决方案2】:

    这个答案很晚,但它可以帮助某人:

    与@ben-marten 的回答相反,切换到外部身份验证确实支持名册管理。

    当您将某人添加到名册时,ejabberd 正在“调用”isuser 操作 - 检查它是否是有效用户 - 您必须在脚本中提供该方法:参见 ejabberd Developers Guide - External Authentication

    我忽略了该操作,我无法将用户添加到名册中。

    其他脚本示例见Authentication Scripts

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 2017-01-26
      • 2015-07-29
      • 2013-12-20
      相关资源
      最近更新 更多