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); + } +}