Add authsympa module
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1224 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
69
authsympa.php
Normal file
69
authsympa.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?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
|
||||||
|
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 substriber, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user