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/BridgeHtpasswd.php | |
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/BridgeHtpasswd.php')
-rw-r--r-- | plugins/htpasswd/BridgeHtpasswd.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/htpasswd/BridgeHtpasswd.php b/plugins/htpasswd/BridgeHtpasswd.php new file mode 100644 index 0000000..51b6a94 --- /dev/null +++ b/plugins/htpasswd/BridgeHtpasswd.php @@ -0,0 +1,19 @@ +<?php + +/** + * Implements EjabberdAuthBridge. + */ +class BridgeHtpasswd extends EjabberdAuthBridge { + function __construct($data, $config) { + $this->data = $data; + $this->config = $config; + } + + function isuser($username, $server) { + return array_key_exists($username, $this->data); + } + + function auth($username, $server, $password) { + return $this->isuser($username, $server) && htpasswd_check($password, $this->data[$username], $this->config); + } +} |