Commit 090ecaa5 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Résolution définitive du bug lié aux données de login résiduelles en mémoire après déconnexion.

Utilisation de la config pour la recherche LDAP en cas d'usurpation d'identité.
Mise en place d'un EventManager unique et dédié à UnicaenAuth
parent 9077cae7
Pipeline #5941 failed with stage
in 10 seconds
...@@ -494,6 +494,7 @@ return [ ...@@ -494,6 +494,7 @@ return [
'UnicaenApp\HistoriqueListener' => HistoriqueListenerFactory::class, 'UnicaenApp\HistoriqueListener' => HistoriqueListenerFactory::class,
'UnicaenAuth\HistoriqueListener' => HistoriqueListenerFactory::class, 'UnicaenAuth\HistoriqueListener' => HistoriqueListenerFactory::class,
\UnicaenAuth\Event\EventManager::class => \UnicaenAuth\Event\EventManagerFactory::class,
], ],
'lazy_services' => [ 'lazy_services' => [
// Mapping services to their class names is required since the ServiceManager is not a declarative DIC. // Mapping services to their class names is required since the ServiceManager is not a declarative DIC.
......
...@@ -6,7 +6,7 @@ use Interop\Container\ContainerInterface; ...@@ -6,7 +6,7 @@ use Interop\Container\ContainerInterface;
use UnicaenApp\Exception\LogicException; use UnicaenApp\Exception\LogicException;
use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Options\ModuleOptions;
use UnicaenAuth\Service\User; use UnicaenAuth\Service\User;
use Zend\EventManager\EventManager; use UnicaenAuth\Event\EventManager;
use Zend\EventManager\EventManagerAwareInterface; use Zend\EventManager\EventManagerAwareInterface;
use Zend\Router\Http\TreeRouteStack; use Zend\Router\Http\TreeRouteStack;
use Zend\ServiceManager\AbstractFactoryInterface; use Zend\ServiceManager\AbstractFactoryInterface;
...@@ -62,10 +62,13 @@ class AbstractFactory implements AbstractFactoryInterface ...@@ -62,10 +62,13 @@ class AbstractFactory implements AbstractFactoryInterface
if ($adapter instanceof EventManagerAwareInterface) { if ($adapter instanceof EventManagerAwareInterface) {
/** @var EventManager $eventManager */ /** @var EventManager $eventManager */
$eventManager = $container->get('EventManager'); $eventManager = $container->get(EventManager::class);
$adapter->setEventManager($eventManager); $adapter->setEventManager($eventManager);
$userService = $container->get('unicaen-auth_user_service'); /* @var $userService \UnicaenAuth\Service\User */ $userService = $container->get('unicaen-auth_user_service'); /* @var $userService \UnicaenAuth\Service\User */
$eventManager->attach('userAuthenticated', [$userService, 'userAuthenticated'], 100); $eventManager->attach('userAuthenticated', [$userService, 'userAuthenticated'], 100);
$eventManager->attach('clear', function() use ($adapter){
$adapter->getStorage()->clear();
});
} }
return $adapter; return $adapter;
......
...@@ -78,15 +78,6 @@ class Cas extends AbstractAdapter implements EventManagerAwareInterface ...@@ -78,15 +78,6 @@ class Cas extends AbstractAdapter implements EventManagerAwareInterface
$this->router = $router; $this->router = $router;
} }
public function getStorage()
{
if (null === $this->storage) {
$this->setStorage(new Session());
}
return $this->storage;
}
/** /**
* Réalise l'authentification. * Réalise l'authentification.
* *
......
...@@ -37,15 +37,6 @@ class Db extends \ZfcUser\Authentication\Adapter\Db implements ServiceLocatorAwa ...@@ -37,15 +37,6 @@ class Db extends \ZfcUser\Authentication\Adapter\Db implements ServiceLocatorAwa
return $this; return $this;
} }
public function getStorage()
{
if (null === $this->storage) {
$this->setStorage(new Session());
}
return $this->storage;
}
/** /**
* Authentification. * Authentification.
* *
......
...@@ -78,15 +78,6 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface ...@@ -78,15 +78,6 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface
$this->appModuleOptions = $appModuleOptions; $this->appModuleOptions = $appModuleOptions;
} }
public function getStorage()
{
if (null === $this->storage) {
$this->setStorage(new Session());
}
return $this->storage;
}
/** /**
* *
* @param EventInterface $e * @param EventInterface $e
...@@ -224,7 +215,7 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface ...@@ -224,7 +215,7 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface
// verif existence du login usurpé // verif existence du login usurpé
if ($this->usernameUsurpe) { if ($this->usernameUsurpe) {
// s'il nexiste pas, échec de l'authentification // s'il nexiste pas, échec de l'authentification
if (!$this->getLdapAuthAdapter()->getLdap()->searchEntries("(supannAliasLogin=$this->usernameUsurpe)")) { if (!@$this->getLdapAuthAdapter()->getLdap()->searchEntries("(".$this->getOptions()->getLdapUsername()."=$this->usernameUsurpe)")) {
$this->usernameUsurpe = null; $this->usernameUsurpe = null;
$success = false; $success = false;
} }
......
...@@ -163,9 +163,6 @@ class Chain implements StorageInterface, EventManagerAwareInterface ...@@ -163,9 +163,6 @@ class Chain implements StorageInterface, EventManagerAwareInterface
*/ */
public function getEventManager() public function getEventManager()
{ {
if (null === $this->eventManager) {
$this->eventManager = new EventManager();
}
return $this->eventManager; return $this->eventManager;
} }
......
...@@ -4,7 +4,7 @@ namespace UnicaenAuth\Authentication\Storage; ...@@ -4,7 +4,7 @@ namespace UnicaenAuth\Authentication\Storage;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Options\ModuleOptions;
use Zend\EventManager\EventManager; use UnicaenAuth\Event\EventManager;
use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\ServiceLocatorInterface;
...@@ -33,7 +33,7 @@ class ChainServiceFactory implements FactoryInterface ...@@ -33,7 +33,7 @@ class ChainServiceFactory implements FactoryInterface
$chain = new Chain(); $chain = new Chain();
/** @var EventManager $eventManager */ /** @var EventManager $eventManager */
$eventManager = $container->get('EventManager'); $eventManager = $container->get(EventManager::class);
$chain->setEventManager($eventManager); $chain->setEventManager($eventManager);
......
<?php
namespace UnicaenAuth\Event;
class EventManager extends \Zend\EventManager\EventManager
{
}
\ No newline at end of file
<?php
namespace UnicaenAuth\Event;
use Interop\Container\ContainerInterface;
/**
* Description of EventManagerFactory
*
* @author LECLUSE Laurent <laurent.lecluse at unicaen.fr>
*/
class EventManagerFactory
{
/**
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
*
* @return EventManager
*/
public function __invoke(ContainerInterface $container, $requestedName, $options = null)
{
$shared = $container->has('SharedEventManager') ? $container->get('SharedEventManager') : null;
$eventManager = new EventManager($shared);
return $eventManager;
}
}
\ No newline at end of file
...@@ -4,8 +4,8 @@ namespace UnicaenAuth\Provider\Identity; ...@@ -4,8 +4,8 @@ namespace UnicaenAuth\Provider\Identity;
use BjyAuthorize\Service\Authorize; use BjyAuthorize\Service\Authorize;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use UnicaenAuth\Event\EventManager;
use UnicaenAuth\Service\UserContext; use UnicaenAuth\Service\UserContext;
use Zend\EventManager\EventManager;
use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\ServiceLocatorInterface;
...@@ -32,7 +32,7 @@ class ChainServiceFactory implements FactoryInterface ...@@ -32,7 +32,7 @@ class ChainServiceFactory implements FactoryInterface
$authorizeService = $container->get('BjyAuthorize\Service\Authorize'); $authorizeService = $container->get('BjyAuthorize\Service\Authorize');
/** @var EventManager $eventManager */ /** @var EventManager $eventManager */
$eventManager = $container->get('EventManager'); $eventManager = $container->get(EventManager::class);
$chain->setUserContextService($userContextService); $chain->setUserContextService($userContextService);
$chain->setAuthorizeService($authorizeService); $chain->setAuthorizeService($authorizeService);
......
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