deceze / ejabberd-extauth-php Goto Github PK
View Code? Open in Web Editor NEWA modern PHP script to use as extauth provider for an ejabberd server.
A modern PHP script to use as extauth provider for an ejabberd server.
Hi,
I am using this library but cannot make it work. When I try to authenticate I get this message from ejabberd
extauth call '[<<"auth">>,<<"admin">>,<<"localhost">>,<<"123456">>]' didn't receive response.
I am using ejabberd version 17.01. Maybe it's a version issue as this script is pretty old.
here is my config:
auth_method: external
extauth_program: "/var/www/html/jabberd/index.php"
This is index.php
#!/usr/bin/php
<?php
require_once '/var/www/html/jabberd/EjabberdAuth.php';
$dbServer = 'localhost';
$dbUser = 'root';
$dbPassword = '12345';
$dbName = 'ejabberd';
$pdo = new PDO('mysql:host=' . $dbServer . ';dbname=' . $dbName, $dbUser, $dbPassword);
new EjabberdAuth($pdo, 'ejabberd-auth.log');
And this is the EjabberdAuth
class:
#!/usr/bin/php
<?php
require_once 'ejabberd_external_auth.php';
class EjabberdAuth extends EjabberdExternalAuth {
/**
* Actual authentication against the database
*/
protected function authenticate($user, $server, $password) {
$this->log('Authenticate method called .... ', LOG_INFO);
$stmt = $this->db()->prepare("SELECT * FROM `users` WHERE username = ? AND password = ? ");
$stmt->execute(array($user, $password));
if($stmt->rowCount() > 0 )
{
return true;
}
else
{
return false;
}
}
/**
* Check if a username already exists
*/
protected function exists($user, $server) {
$stmt = $this->db()->prepare("SELECT * FROM `users` WHERE username = ? ");
$stmt->execute(array($user));
if($stmt->rowCount() > 0 )
{
return true;
}
else
{
return false;
}
}
}
But nothing is logged and i am not getting any response. I made intentional errors in it to check if I get any error messages, which I get. So the script is being called. Can't figure out the issue.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.