diff options
author | Christoph Burschka | 2014-11-16 14:01:10 +0100 |
---|---|---|
committer | Christoph Burschka | 2014-11-16 14:01:10 +0100 |
commit | b54236dceeedbf33796dcdb8319bc72f923584bb (patch) | |
tree | 04a69e3cd48b0b34fa80dee69adca289d9dbd530 /plugins/htpasswd/htpasswd.module | |
parent | Update README for ejabberd 13.10+ (diff) | |
download | ejabberd-auth-php-b54236dceeedbf33796dcdb8319bc72f923584bb.tar.gz |
Fix #8: Add htpasswd authentication
ejabberd can now authenticate against Apache auth files.
Diffstat (limited to 'plugins/htpasswd/htpasswd.module')
-rw-r--r-- | plugins/htpasswd/htpasswd.module | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/htpasswd/htpasswd.module b/plugins/htpasswd/htpasswd.module new file mode 100644 index 0000000..b97de52 --- /dev/null +++ b/plugins/htpasswd/htpasswd.module @@ -0,0 +1,18 @@ +<?php + +function htpasswd_init($config) { + $data = array(); + $file = $config['htpasswd_file']; + if (file_exists($file) && is_readable($file)) { + $lines = explode("\n", trim(file_get_contents($file))); + foreach ($lines as $line) { + list($user, $password) = explode(":", trim($line), 2); + $data[$user] = $password; + } + } + + // Load the plugin. + require_once __DIR__ . '/BridgeHtpasswd.php'; + require_once __DIR__ . '/htpasswd.inc'; + return new BridgeHtpasswd($data, $config); +} |