Loading src/UnicaenAuth/Authentication/Storage/ChainServiceFactory.php +9 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace UnicaenAuth\Authentication\Storage; use UnicaenAuth\Options\ModuleOptions; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; Loading Loading @@ -31,6 +32,14 @@ class ChainServiceFactory implements FactoryInterface { $chain = new Chain(); /** @var ModuleOptions $options */ $options = $serviceLocator->get('unicaen-auth_module_options'); // retrait du fournisseur Ldap si l'auth LDAP est désactivée if (isset($options->getLdap()['enabled']) && ! $options->getLdap()['enabled']) { unset($this->mandatoryStorages[200]); } $storages = $this->mandatoryStorages + $this->storages; krsort($storages); Loading src/UnicaenAuth/Provider/Identity/ChainServiceFactory.php +27 −7 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Provider\Identity; use Zend\ServiceManager\FactoryInterface; Loading @@ -19,16 +20,11 @@ class ChainServiceFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); //'unicaen-auth_module_options' if (!isset($config['unicaen-auth']['identity_providers']) || !$config['unicaen-auth']['identity_providers']) { throw new \UnicaenApp\Exception\RuntimeException("Aucun fournisseur d'identité spécifié dans la config."); } $providers = (array) $config['unicaen-auth']['identity_providers']; $chain = new Chain(); $chain->setServiceLocator($serviceLocator); $providers = $this->computeProviders($serviceLocator); foreach ($providers as $priority => $name) { $provider = $serviceLocator->get($name); $chain->getEventManager()->attach('getIdentityRoles', [$provider, 'injectIdentityRoles'], $priority); Loading @@ -36,4 +32,28 @@ class ChainServiceFactory implements FactoryInterface return $chain; } /** * @param ServiceLocatorInterface $serviceLocator * @return array */ private function computeProviders(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); //'unicaen-auth_module_options' if (! isset($config['unicaen-auth']['identity_providers']) || ! $config['unicaen-auth']['identity_providers']) { throw new \UnicaenApp\Exception\RuntimeException("Aucun fournisseur d'identité spécifié dans la config."); } $providers = (array) $config['unicaen-auth']['identity_providers']; // retrait du fournisseur 'Ldap' si l'auth Ldap est désactivée if (isset($config['unicaen-auth']['ldap']['enabled']) && ! $config['unicaen-auth']['ldap']['enabled']) { $key = array_search('UnicaenAuth\Provider\Identity\Ldap', $providers, true); if ($key !== false) { unset($providers[$key]); } } return $providers; } } No newline at end of file Loading
src/UnicaenAuth/Authentication/Storage/ChainServiceFactory.php +9 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace UnicaenAuth\Authentication\Storage; use UnicaenAuth\Options\ModuleOptions; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; Loading Loading @@ -31,6 +32,14 @@ class ChainServiceFactory implements FactoryInterface { $chain = new Chain(); /** @var ModuleOptions $options */ $options = $serviceLocator->get('unicaen-auth_module_options'); // retrait du fournisseur Ldap si l'auth LDAP est désactivée if (isset($options->getLdap()['enabled']) && ! $options->getLdap()['enabled']) { unset($this->mandatoryStorages[200]); } $storages = $this->mandatoryStorages + $this->storages; krsort($storages); Loading
src/UnicaenAuth/Provider/Identity/ChainServiceFactory.php +27 −7 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Provider\Identity; use Zend\ServiceManager\FactoryInterface; Loading @@ -19,16 +20,11 @@ class ChainServiceFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); //'unicaen-auth_module_options' if (!isset($config['unicaen-auth']['identity_providers']) || !$config['unicaen-auth']['identity_providers']) { throw new \UnicaenApp\Exception\RuntimeException("Aucun fournisseur d'identité spécifié dans la config."); } $providers = (array) $config['unicaen-auth']['identity_providers']; $chain = new Chain(); $chain->setServiceLocator($serviceLocator); $providers = $this->computeProviders($serviceLocator); foreach ($providers as $priority => $name) { $provider = $serviceLocator->get($name); $chain->getEventManager()->attach('getIdentityRoles', [$provider, 'injectIdentityRoles'], $priority); Loading @@ -36,4 +32,28 @@ class ChainServiceFactory implements FactoryInterface return $chain; } /** * @param ServiceLocatorInterface $serviceLocator * @return array */ private function computeProviders(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); //'unicaen-auth_module_options' if (! isset($config['unicaen-auth']['identity_providers']) || ! $config['unicaen-auth']['identity_providers']) { throw new \UnicaenApp\Exception\RuntimeException("Aucun fournisseur d'identité spécifié dans la config."); } $providers = (array) $config['unicaen-auth']['identity_providers']; // retrait du fournisseur 'Ldap' si l'auth Ldap est désactivée if (isset($config['unicaen-auth']['ldap']['enabled']) && ! $config['unicaen-auth']['ldap']['enabled']) { $key = array_search('UnicaenAuth\Provider\Identity\Ldap', $providers, true); if ($key !== false) { unset($providers[$key]); } } return $providers; } } No newline at end of file