Loading config/module.config.php +0 −5 Original line number Diff line number Diff line <?php use UnicaenAuth\Authentication\Adapter\ShibSimulatorAdapter; use UnicaenAuth\Authentication\Storage\ShibSimulatorStorage; use UnicaenAuth\Controller\AuthControllerFactory; use UnicaenAuth\Service\ShibService; use UnicaenAuth\Service\ShibServiceFactory; use UnicaenAuth\Service\UserContextFactory; use UnicaenAuth\View\Helper\ShibConnectViewHelperFactory; use UnicaenAuth\View\Helper\UserUsurpationHelperFactory; $settings = [ /** Loading Loading @@ -376,7 +373,6 @@ return [ 'UnicaenAuth\Authentication\Storage\Db' => 'UnicaenAuth\Authentication\Storage\Db', 'UnicaenAuth\Authentication\Storage\Ldap' => 'UnicaenAuth\Authentication\Storage\Ldap', 'UnicaenAuth\Authentication\Storage\Shib' => 'UnicaenAuth\Authentication\Storage\Shib', 'UnicaenAuth\Authentication\Storage\ShibSimulatorStorage' => ShibSimulatorStorage::class, 'UnicaenAuth\View\RedirectionStrategy' => 'UnicaenAuth\View\RedirectionStrategy', 'UnicaenAuth\Service\User' => 'UnicaenAuth\Service\User', 'UnicaenAuth\Service\CategoriePrivilege' => 'UnicaenAuth\Service\CategoriePrivilegeService', Loading Loading @@ -436,7 +432,6 @@ return [ 'userInfo' => 'UnicaenAuth\View\Helper\UserInfoFactory', 'userProfileSelect' => 'UnicaenAuth\View\Helper\UserProfileSelectFactory', 'userProfileSelectRadioItem' => 'UnicaenAuth\View\Helper\UserProfileSelectRadioItemFactory', 'userUsurpation' => UserUsurpationHelperFactory::class, 'shibConnect' => ShibConnectViewHelperFactory::class, ], 'invokables' => [ Loading src/UnicaenAuth/Authentication/Adapter/Cas.php +2 −39 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Authentication\Adapter; use phpCAS; use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper; use UnicaenApp\Exception; use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Service\User; use Zend\Authentication\Exception\UnexpectedValueException; use Zend\Authentication\Result as AuthenticationResult; use Zend\EventManager\EventManager; Loading Loading @@ -50,11 +48,6 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event */ protected $casClient; /** * @var LdapPeopleMapper */ protected $ldapPeopleMapper; /** * Réalise l'authentification. * Loading Loading @@ -101,12 +94,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event $e->setCode(AuthenticationResult::SUCCESS) ->setMessages(['Authentication successful.']); // recherche de l'individu dans l'annuaire LDAP (il existe forcément puisque l'auth CAS a réussi) $ldapPeople = $this->getLdapPeopleMapper()->findOneByUsername($identity); /* @var $userService User */ $userService = $this->getServiceManager()->get('unicaen-auth_user_service'); $userService->userAuthenticated($ldapPeople); $this->getEventManager()->trigger('userAuthenticated', $e); } /** Loading Loading @@ -198,31 +186,6 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event return $this->options; } /** * get ldap people mapper * * @return LdapPeopleMapper */ public function getLdapPeopleMapper() { if (null === $this->ldapPeopleMapper) { $this->ldapPeopleMapper = $this->getServiceManager()->get('ldap_people_mapper'); } return $this->ldapPeopleMapper; } /** * set ldap people mapper * * @param LdapPeopleMapper $mapper * @return self */ public function setLdapPeopleMapper(LdapPeopleMapper $mapper) { $this->ldapPeopleMapper = $mapper; return $this; } /** * Get service manager * Loading src/UnicaenAuth/Authentication/Storage/ChainServiceFactory.php +2 −9 Original line number Diff line number Diff line Loading @@ -12,15 +12,11 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class ChainServiceFactory implements FactoryInterface { private $mandatoryStorages = [ protected $storages = [ 200 => 'UnicaenAuth\Authentication\Storage\Ldap', 100 => 'UnicaenAuth\Authentication\Storage\Db', 76 => 'UnicaenAuth\Authentication\Storage\ShibSimulatorStorage', 75 => 'UnicaenAuth\Authentication\Storage\Shib', ]; protected $storages = []; /** * Create service * Loading @@ -31,10 +27,7 @@ class ChainServiceFactory implements FactoryInterface { $chain = new Chain(); $storages = $this->mandatoryStorages + $this->storages; krsort($storages); foreach ($storages as $priority => $name) { foreach ($this->storages as $priority => $name) { $storage = $serviceLocator->get($name); $chain->getEventManager()->attach('read', [$storage, 'read'], $priority); $chain->getEventManager()->attach('write', [$storage, 'write'], $priority); Loading src/UnicaenAuth/Authentication/Storage/Shib.php +9 −18 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenAuth\Authentication\Storage; use UnicaenAuth\Entity\Shibboleth\ShibUser; use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Service\ShibService; use Zend\Authentication\Storage\Session; use Zend\Authentication\Storage\StorageInterface; Loading @@ -24,6 +25,11 @@ class Shib implements ChainableStorage, ServiceLocatorAwareInterface */ protected $storage; /** * @var ModuleOptions */ protected $options; /** * @var ShibUser */ Loading @@ -45,28 +51,13 @@ class Shib implements ChainableStorage, ServiceLocatorAwareInterface */ public function read(ChainEvent $e) { $shibUser = $this->getAuthenticatedUser(); $e->addContents('shib', $shibUser); return $shibUser; } /** * @return null|ShibUser */ private function getAuthenticatedUser() { if (null !== $this->resolvedIdentity) { return $this->resolvedIdentity; } /** @var ShibService $shib */ $shib = $this->getServiceLocator()->get(ShibService::class); $shibUser = $shib->getAuthenticatedUser(); $this->resolvedIdentity = $shib->getAuthenticatedUser(); $e->addContents('shib', $shibUser); return $this->resolvedIdentity; return $shibUser; } /** Loading src/UnicaenAuth/Authentication/Storage/ShibSimulatorStorage.phpdeleted 100644 → 0 +0 −70 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Authentication\Storage; use UnicaenAuth\Service\ShibService; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorAwareTrait; /** * Storage permettant de simuler un utilisateur authentifié via Shibboleth. * * @author Unicaen */ class ShibSimulatorStorage implements ChainableStorage, ServiceLocatorAwareInterface { use ServiceLocatorAwareTrait; /** * @var ShibService */ protected $shibService; /** * @var array */ protected $shibbolethOptions; /** * {@inheritdoc} */ public function read(ChainEvent $e) { if (! $this->getShibService()->isShibbolethEnabled()) { return; } if (! $this->getShibService()->isSimulationActive()) { return; } $this->getShibService()->handleSimulation(); } /** * {@inheritdoc} */ public function write(ChainEvent $e) { // nop } /** * {@inheritdoc} */ public function clear(ChainEvent $e) { // nop } /** * @return ShibService */ private function getShibService() { if ($this->shibService === null) { $this->shibService = $this->serviceLocator->get(ShibService::class); } return $this->shibService; } } No newline at end of file Loading
config/module.config.php +0 −5 Original line number Diff line number Diff line <?php use UnicaenAuth\Authentication\Adapter\ShibSimulatorAdapter; use UnicaenAuth\Authentication\Storage\ShibSimulatorStorage; use UnicaenAuth\Controller\AuthControllerFactory; use UnicaenAuth\Service\ShibService; use UnicaenAuth\Service\ShibServiceFactory; use UnicaenAuth\Service\UserContextFactory; use UnicaenAuth\View\Helper\ShibConnectViewHelperFactory; use UnicaenAuth\View\Helper\UserUsurpationHelperFactory; $settings = [ /** Loading Loading @@ -376,7 +373,6 @@ return [ 'UnicaenAuth\Authentication\Storage\Db' => 'UnicaenAuth\Authentication\Storage\Db', 'UnicaenAuth\Authentication\Storage\Ldap' => 'UnicaenAuth\Authentication\Storage\Ldap', 'UnicaenAuth\Authentication\Storage\Shib' => 'UnicaenAuth\Authentication\Storage\Shib', 'UnicaenAuth\Authentication\Storage\ShibSimulatorStorage' => ShibSimulatorStorage::class, 'UnicaenAuth\View\RedirectionStrategy' => 'UnicaenAuth\View\RedirectionStrategy', 'UnicaenAuth\Service\User' => 'UnicaenAuth\Service\User', 'UnicaenAuth\Service\CategoriePrivilege' => 'UnicaenAuth\Service\CategoriePrivilegeService', Loading Loading @@ -436,7 +432,6 @@ return [ 'userInfo' => 'UnicaenAuth\View\Helper\UserInfoFactory', 'userProfileSelect' => 'UnicaenAuth\View\Helper\UserProfileSelectFactory', 'userProfileSelectRadioItem' => 'UnicaenAuth\View\Helper\UserProfileSelectRadioItemFactory', 'userUsurpation' => UserUsurpationHelperFactory::class, 'shibConnect' => ShibConnectViewHelperFactory::class, ], 'invokables' => [ Loading
src/UnicaenAuth/Authentication/Adapter/Cas.php +2 −39 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Authentication\Adapter; use phpCAS; use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper; use UnicaenApp\Exception; use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Service\User; use Zend\Authentication\Exception\UnexpectedValueException; use Zend\Authentication\Result as AuthenticationResult; use Zend\EventManager\EventManager; Loading Loading @@ -50,11 +48,6 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event */ protected $casClient; /** * @var LdapPeopleMapper */ protected $ldapPeopleMapper; /** * Réalise l'authentification. * Loading Loading @@ -101,12 +94,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event $e->setCode(AuthenticationResult::SUCCESS) ->setMessages(['Authentication successful.']); // recherche de l'individu dans l'annuaire LDAP (il existe forcément puisque l'auth CAS a réussi) $ldapPeople = $this->getLdapPeopleMapper()->findOneByUsername($identity); /* @var $userService User */ $userService = $this->getServiceManager()->get('unicaen-auth_user_service'); $userService->userAuthenticated($ldapPeople); $this->getEventManager()->trigger('userAuthenticated', $e); } /** Loading Loading @@ -198,31 +186,6 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event return $this->options; } /** * get ldap people mapper * * @return LdapPeopleMapper */ public function getLdapPeopleMapper() { if (null === $this->ldapPeopleMapper) { $this->ldapPeopleMapper = $this->getServiceManager()->get('ldap_people_mapper'); } return $this->ldapPeopleMapper; } /** * set ldap people mapper * * @param LdapPeopleMapper $mapper * @return self */ public function setLdapPeopleMapper(LdapPeopleMapper $mapper) { $this->ldapPeopleMapper = $mapper; return $this; } /** * Get service manager * Loading
src/UnicaenAuth/Authentication/Storage/ChainServiceFactory.php +2 −9 Original line number Diff line number Diff line Loading @@ -12,15 +12,11 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class ChainServiceFactory implements FactoryInterface { private $mandatoryStorages = [ protected $storages = [ 200 => 'UnicaenAuth\Authentication\Storage\Ldap', 100 => 'UnicaenAuth\Authentication\Storage\Db', 76 => 'UnicaenAuth\Authentication\Storage\ShibSimulatorStorage', 75 => 'UnicaenAuth\Authentication\Storage\Shib', ]; protected $storages = []; /** * Create service * Loading @@ -31,10 +27,7 @@ class ChainServiceFactory implements FactoryInterface { $chain = new Chain(); $storages = $this->mandatoryStorages + $this->storages; krsort($storages); foreach ($storages as $priority => $name) { foreach ($this->storages as $priority => $name) { $storage = $serviceLocator->get($name); $chain->getEventManager()->attach('read', [$storage, 'read'], $priority); $chain->getEventManager()->attach('write', [$storage, 'write'], $priority); Loading
src/UnicaenAuth/Authentication/Storage/Shib.php +9 −18 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenAuth\Authentication\Storage; use UnicaenAuth\Entity\Shibboleth\ShibUser; use UnicaenAuth\Options\ModuleOptions; use UnicaenAuth\Service\ShibService; use Zend\Authentication\Storage\Session; use Zend\Authentication\Storage\StorageInterface; Loading @@ -24,6 +25,11 @@ class Shib implements ChainableStorage, ServiceLocatorAwareInterface */ protected $storage; /** * @var ModuleOptions */ protected $options; /** * @var ShibUser */ Loading @@ -45,28 +51,13 @@ class Shib implements ChainableStorage, ServiceLocatorAwareInterface */ public function read(ChainEvent $e) { $shibUser = $this->getAuthenticatedUser(); $e->addContents('shib', $shibUser); return $shibUser; } /** * @return null|ShibUser */ private function getAuthenticatedUser() { if (null !== $this->resolvedIdentity) { return $this->resolvedIdentity; } /** @var ShibService $shib */ $shib = $this->getServiceLocator()->get(ShibService::class); $shibUser = $shib->getAuthenticatedUser(); $this->resolvedIdentity = $shib->getAuthenticatedUser(); $e->addContents('shib', $shibUser); return $this->resolvedIdentity; return $shibUser; } /** Loading
src/UnicaenAuth/Authentication/Storage/ShibSimulatorStorage.phpdeleted 100644 → 0 +0 −70 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Authentication\Storage; use UnicaenAuth\Service\ShibService; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorAwareTrait; /** * Storage permettant de simuler un utilisateur authentifié via Shibboleth. * * @author Unicaen */ class ShibSimulatorStorage implements ChainableStorage, ServiceLocatorAwareInterface { use ServiceLocatorAwareTrait; /** * @var ShibService */ protected $shibService; /** * @var array */ protected $shibbolethOptions; /** * {@inheritdoc} */ public function read(ChainEvent $e) { if (! $this->getShibService()->isShibbolethEnabled()) { return; } if (! $this->getShibService()->isSimulationActive()) { return; } $this->getShibService()->handleSimulation(); } /** * {@inheritdoc} */ public function write(ChainEvent $e) { // nop } /** * {@inheritdoc} */ public function clear(ChainEvent $e) { // nop } /** * @return ShibService */ private function getShibService() { if ($this->shibService === null) { $this->shibService = $this->serviceLocator->get(ShibService::class); } return $this->shibService; } } No newline at end of file