Commit 8a0759a6 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Désormais, la déconnexion de l'appli déconnecte du CAS.

parent 3ea205b0
......@@ -51,21 +51,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
error_reporting($oldErrorReporting = error_reporting() & ~E_NOTICE);
require_once __VENDOR_DIR__ . '/gorg/phpcas/CAS.php';
if (!isset($config['connection']['default']['params'])) {
throw new \UnicaenApp\Exception("Les paramètres de connexion au serveur CAS sont invalides.");
}
$options = $config['connection']['default']['params'];
if (array_key_exists('debug', $options) && (bool) $options['debug']) {
\phpCAS::setDebug();
}
// initialize phpCAS
\phpCAS::client($options['version'], $options['hostname'], $options['port'], $options['uri'], true);
// no SSL validation for the CAS server
\phpCAS::setNoCasServerValidation();
$this->initCasClient();
\phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS server
......@@ -94,7 +80,50 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
return true;
}
/**
*
* @param AuthEvent $e
* @see ChainableAdapter
*/
public function logout(AuthEvent $e)
{
if (!$this->getOptions()->getCas()) {
return; // NB: l'authentification CAS est désactivée ssi le tableau des options est vide
}
$this->initCasClient();
if (\phpCAS::isAuthenticated()) {
$urlHelper = $this->getServiceManager()->get('Router'); /* @var $urlHelper \Zend\Mvc\Router\Http\TreeRouteStack */
$returnUrl = $urlHelper->getRequestUri()->setPath($urlHelper->getBaseUrl())->toString();
\phpCAS::logoutWithRedirectService($returnUrl);
}
}
/**
*
* @throws \UnicaenApp\Exception
*/
protected function initCasClient()
{
require_once __VENDOR_DIR__ . '/gorg/phpcas/CAS.php';
$config = $this->getOptions()->getCas();
if (!isset($config['connection']['default']['params'])) {
throw new \UnicaenApp\Exception("Les paramètres de connexion au serveur CAS sont invalides.");
}
$options = $config['connection']['default']['params'];
if (array_key_exists('debug', $options) && (bool) $options['debug']) {
\phpCAS::setDebug();
}
// initialize phpCAS
\phpCAS::client($options['version'], $options['hostname'], $options['port'], $options['uri'], true);
// no SSL validation for the CAS server
\phpCAS::setNoCasServerValidation();
}
/**
* @param ModuleOptions $options
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment