Files
DomFramework/authsympa.php
2014-03-19 18:57:16 +00:00

72 lines
2.3 KiB
PHP

<?php
/** User authentication against SYMPA server
Sympa is a mailling list server. It can handle authentication with
- a username (a email adress)
- a password
- a list to check if the user is recorded in
- a Sympa SOAP server WSDL
- the part of list which should be test : subscriber, owner, editor
It use the SOAP protocol. So the PHP SOAP library is needed and the network
must be open between the Web server and the Sympa server. */
/* POC :
$auth = new authsympa ();
$auth->wsdl = "https://lists.domain.tld/sympa/wsdl";
$auth->list = "listtest@lists.domain.tld";
$auth->connect ();
var_dump ($auth->authentication ("user@domain.tld", "Pa$$word!"));
*/
require_once ("auth.php");
class authsympa extends auth
{
public $wsdl = null;
public $list = null;
public $function = "subscriber"; // can be subscriber, owner, editor
private $client = null;
private $authkey = null;
private $email = null;
public function __construct ()
{
if (! class_exists ("SoapClient"))
throw new Exception (_("No SOAP PHP library available"), 500);
}
public function connect ()
{
if ($this->wsdl === null)
throw new Exception (_("No WSDL provided to Sympa auth"), 401);
$this->client = new SoapClient($this->wsdl);
}
public function authentication ($email, $password)
{
if ($this->client === null)
throw new Exception (_("The SOAP connection is not opened"), 401);
if ($this->list === null)
throw new Exception (_("The list to check is not defined"), 401);
$this->authkey = $this->client->login ($email, $password);
if ($this->authkey === null)
throw new Exception (
_("Can't connect with provided email/password to sympa"),
401);
$this->email = $email;
$rc = $this->client->authenticateAndRun ($email, $this->authkey,
'amI', array ($this->list, $this->function, $email));
if ($rc === null)
return FALSE;
return $rc;
}
public function getdetails ()
{
throw new Exception (_("The details can't be provided by Sympa"), 404);
}
public function changepassword ($oldpassword, $newpassword)
{
throw new Exception (_("The password can't be change for SYMPA users"),
405);
}
}