4 * ejabberd extauth script for the integration with friendica
6 * Originally written for joomla by Dalibor Karlovic <dado@krizevci.info>
7 * modified for Friendica by Michael Vogel <icarus@dabo.de>
10 * Latest version of the original script for joomla is available at:
11 * http://87.230.15.86/~dado/ejabberd/joomla-login
15 * - Change it's owner to whichever user is running the server, ie. ejabberd
16 * $ chown ejabberd:ejabberd /path/to/friendica/bin/auth_ejabberd.php
18 * - Change the access mode so it is readable only to the user ejabberd and has exec
19 * $ chmod 700 /path/to/friendica/bin/auth_ejabberd.php
21 * - Edit your ejabberd.cfg file, comment out your auth_method and add:
22 * {auth_method, external}.
23 * {extauth_program, "/path/to/friendica/bin/auth_ejabberd.php"}.
25 * - Restart your ejabberd service, you should be able to login with your friendica auth info
28 * - if your users have a space or a @ in their nickname, they'll run into trouble
29 * registering with any client so they should be instructed to replace these chars
30 * " " (space) is replaced with "%20"
31 * "@" is replaced with "(a)"
36 use Friendica\App\Mode;
37 use Friendica\BaseObject;
38 use Friendica\Util\ExAuth;
39 use Psr\Log\LoggerInterface;
41 if (sizeof($_SERVER["argv"]) == 0) {
45 $directory = dirname($_SERVER["argv"][0]);
47 if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
48 $directory = $_SERVER["PWD"] . DIRECTORY_SEPARATOR . $directory;
51 $directory = realpath($directory . DIRECTORY_SEPARATOR . "..");
55 require dirname(__DIR__) . '/vendor/autoload.php';
57 $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
58 $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['auth_ejabberd']]);
60 BaseObject::setDependencyInjection($dice);
62 $appMode = $dice->create(Mode::class);
64 if ($appMode->isNormal()) {
65 $oAuth = new ExAuth();