From 687ebfab9aa64f3b9b4ee61310d96e91ad017250 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 19 Mar 2014 12:24:05 +0000 Subject: [PATCH] Add authsympa module git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1224 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authsympa.php | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 authsympa.php diff --git a/authsympa.php b/authsympa.php new file mode 100644 index 0000000..364cc08 --- /dev/null +++ b/authsympa.php @@ -0,0 +1,69 @@ +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); + } +}