ejabberd: Saving of roster not working with external Authentication Script enabled

StackOverflow https://stackoverflow.com/questions/20960476

  •  25-09-2022
  •  | 
  •  

سؤال

I have successfully configured an ejabberd server with an extauth script (perl). It is working correctly and only allowing users from my mysql DB.

But following features are not working anymore: roster management, adding users to rosters, authorization of users (for adding them to the roster) With the internal auth it works. Both times ejabberd is configured to use the internal amnesia db.

Please help me figure out, why it is not working with extauth enabled. Do I have to write my own methods in the extauth script? (That I don't really want...)

هل كانت مفيدة؟

المحلول

So after doing some research on my problem, I think that switching to the external authentication will not support roster management.

What I ended up doing is swichting back to internal authentication and using mod_admin_extra to add users and update passwords with this php script:

<?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;
}

?>

Hope this helps someone!

نصائح أخرى

This answer is late but it could help someone:

Contrary to @ben-marten's answer, Switching to the external authentication does support roster management.

When you add someone to the roster, ejabberd is 'calling' the isuser operation - check if it’s a valid user - you have to provide that method in the script: see ejabberd Developers Guide - External Authentication

I ignored that operation, and I could not add a user to the roster.

For other script examples see Authentication Scripts

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top