Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auth_ejabberd.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * ejabberd extauth script for the integration with friendica
  5. *
  6. * Originally written for joomla by Dalibor Karlovic <dado@krizevci.info>
  7. * modified for Friendica by Michael Vogel <icarus@dabo.de>
  8. * published under GPL
  9. *
  10. * Latest version of the original script for joomla is available at:
  11. * http://87.230.15.86/~dado/ejabberd/joomla-login
  12. *
  13. * Installation:
  14. *
  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
  17. *
  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
  20. *
  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"}.
  24. *
  25. * - Restart your ejabberd service, you should be able to login with your friendica auth info
  26. *
  27. * Other hints:
  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)"
  32. *
  33. */
  34. use Friendica\App;
  35. use Friendica\Core\Config\Cache;
  36. use Friendica\Factory;
  37. use Friendica\Util\BasePath;
  38. use Friendica\Util\ExAuth;
  39. if (sizeof($_SERVER["argv"]) == 0) {
  40. die();
  41. }
  42. $directory = dirname($_SERVER["argv"][0]);
  43. if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
  44. $directory = $_SERVER["PWD"] . DIRECTORY_SEPARATOR . $directory;
  45. }
  46. $directory = realpath($directory . DIRECTORY_SEPARATOR . "..");
  47. chdir($directory);
  48. require dirname(__DIR__) . '/vendor/autoload.php';
  49. $basedir = BasePath::create(dirname(__DIR__), $_SERVER);
  50. $configLoader = new Cache\ConfigCacheLoader($basedir);
  51. $configCache = Factory\ConfigFactory::createCache($configLoader);
  52. Factory\DBFactory::init($configCache, $_SERVER);
  53. $config = Factory\ConfigFactory::createConfig($configCache);
  54. $pconfig = Factory\ConfigFactory::createPConfig($configCache);
  55. $logger = Factory\LoggerFactory::create('auth_ejabberd', $config);
  56. $profiler = Factory\ProfilerFactory::create($logger, $config);
  57. $a = new App($config, $logger, $profiler);
  58. if ($a->getMode()->isNormal()) {
  59. $oAuth = new ExAuth();
  60. $oAuth->readStdin();
  61. }