summaryrefslogtreecommitdiff
path: root/plugins/htpasswd/BridgeHtpasswd.php
diff options
context:
space:
mode:
authorChristoph Burschka2014-11-16 14:01:10 +0100
committerChristoph Burschka2014-11-16 14:01:10 +0100
commitb54236dceeedbf33796dcdb8319bc72f923584bb (patch)
tree04a69e3cd48b0b34fa80dee69adca289d9dbd530 /plugins/htpasswd/BridgeHtpasswd.php
parentUpdate README for ejabberd 13.10+ (diff)
downloadejabberd-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.php19
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);
+ }
+}