Loading config/module.config.php +1 −5 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ $settings = [ 'enabled' => false, 'adapter' => Ldap::class, 'form' => LoginForm::class, 'username' => 'supannaliaslogin', 'log_failures' => false, /** @see \UnicaenAuthentification\Event\Listener\LdapAuthenticationFailureLoggerListener */ ], ], Loading Loading @@ -259,11 +260,6 @@ $settings = [ 200 => 'UnicaenAuthentification\Provider\Identity\Db', // en 2e 100 => 'UnicaenAuthentification\Provider\Identity\Ldap', // en 3e @deprecated ], /** * Attribut LDAP utilisé pour le username des utilisateurs */ 'ldap_username' => 'supannaliaslogin', ]; return [ Loading config/unicaen-authentification.global.php.dist +8 −5 Original line number Diff line number Diff line Loading @@ -14,11 +14,14 @@ return [ 'entity_manager_name' => 'doctrine.entitymanager.orm_default', // nom du gestionnaire d'entités à utiliser 'local' => [ 'ldap' => [ /** * Attribut LDAP utilisé pour le username des utilisateurs * A personnaliser au besoin * Attribut LDAP utilisé pour le username des utilisateurs : à personnaliser au besoin. */ //'ldap_username' => 'supannaliaslogin', 'username' => 'supannaliaslogin', ], ], ], ]; Loading src/UnicaenAuthentification/Authentication/Adapter/Ldap.php +1 −1 Original line number Diff line number Diff line Loading @@ -227,7 +227,7 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface if ($this->usernameUsurpe) { // s'il nexiste pas, échec de l'authentification if (!@$this->getLdapAuthAdapter()->getLdap()->searchEntries( "(" . $this->moduleOptions->getLdapUsername() . "=$this->usernameUsurpe)" "(" . $this->moduleOptions->getLdap()['username'] . "=$this->usernameUsurpe)" )) { $this->usernameUsurpe = null; $success = false; Loading src/UnicaenAuthentification/Options/ModuleOptions.php +10 −9 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace UnicaenAuthentification\Options; use BadMethodCallException; /** * Classe encapsulant les options de fonctionnement du module. * Loading Loading @@ -228,22 +230,21 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions } /** * @return string * @deprecated Méthode condamnée, utilisez explicitement ```getLdap()['username']``` */ public function getLdapUsername(): string { return $this->ldapUsername; return $this->getLdap()['username']; } /** * @param string $ldapUsername * @return self * @deprecated Cette méthode n'a plus de sens depuis l'abandon de la clé 'ldap_username' (devenue 'local.ldap.username') */ public function setLdapUsername(string $ldapUsername): self public function setLdapUsername(): self { $this->ldapUsername = $ldapUsername; return $this; throw new BadMethodCallException( "Cette méthode n'a plus de sens depuis l'abandon de la clé 'ldap_username' (devenue 'local.ldap.username')" ); } /** Loading Loading @@ -346,7 +347,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions { try { return parent::__get($key); } catch (\BadMethodCallException $e) { } catch (BadMethodCallException $e) { if (array_key_exists($key, $this->originalOptions)) { return $this->originalOptions[$key]; } else { Loading src/UnicaenAuthentification/Options/ModuleOptionsFactory.php +17 −12 Original line number Diff line number Diff line Loading @@ -4,23 +4,22 @@ namespace UnicaenAuthentification\Options; use Assert\Assertion; use Assert\AssertionFailedException; use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; use UnicaenApp\Exception\RuntimeException; /** * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> */ class ModuleOptionsFactory class ModuleOptionsFactory implements FactoryInterface { protected $class = ModuleOptions::class; protected string $class = ModuleOptions::class; /** * Create service * * @param ContainerInterface $container * @return mixed * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container) public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $config = $container->get('Configuration'); $moduleConfig = $config['unicaen-auth'] ?? []; Loading @@ -31,10 +30,7 @@ class ModuleOptionsFactory return new $this->class($moduleConfig); } /** * @param array $config */ protected function validateConfig(array $config) protected function validateConfig(array $config): void { // // Config authentification shibboleth. Loading Loading @@ -81,5 +77,14 @@ class ModuleOptionsFactory "La clé de config 'unicaen-auth.$k' et son contenu doivent être déplacés sous la nouvelle clé 'unicaen-auth.local'" ); } // // Clé 'ldap_username' transformée. // if (array_key_exists($k = 'ldap_username', $config)) { throw new RuntimeException( "La clé de config 'unicaen-auth.$k' doit être supprimée et son contenu déplacé dans la nouvelle clé 'unicaen-auth.local.ldap.username'" ); } } } No newline at end of file Loading
config/module.config.php +1 −5 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ $settings = [ 'enabled' => false, 'adapter' => Ldap::class, 'form' => LoginForm::class, 'username' => 'supannaliaslogin', 'log_failures' => false, /** @see \UnicaenAuthentification\Event\Listener\LdapAuthenticationFailureLoggerListener */ ], ], Loading Loading @@ -259,11 +260,6 @@ $settings = [ 200 => 'UnicaenAuthentification\Provider\Identity\Db', // en 2e 100 => 'UnicaenAuthentification\Provider\Identity\Ldap', // en 3e @deprecated ], /** * Attribut LDAP utilisé pour le username des utilisateurs */ 'ldap_username' => 'supannaliaslogin', ]; return [ Loading
config/unicaen-authentification.global.php.dist +8 −5 Original line number Diff line number Diff line Loading @@ -14,11 +14,14 @@ return [ 'entity_manager_name' => 'doctrine.entitymanager.orm_default', // nom du gestionnaire d'entités à utiliser 'local' => [ 'ldap' => [ /** * Attribut LDAP utilisé pour le username des utilisateurs * A personnaliser au besoin * Attribut LDAP utilisé pour le username des utilisateurs : à personnaliser au besoin. */ //'ldap_username' => 'supannaliaslogin', 'username' => 'supannaliaslogin', ], ], ], ]; Loading
src/UnicaenAuthentification/Authentication/Adapter/Ldap.php +1 −1 Original line number Diff line number Diff line Loading @@ -227,7 +227,7 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface if ($this->usernameUsurpe) { // s'il nexiste pas, échec de l'authentification if (!@$this->getLdapAuthAdapter()->getLdap()->searchEntries( "(" . $this->moduleOptions->getLdapUsername() . "=$this->usernameUsurpe)" "(" . $this->moduleOptions->getLdap()['username'] . "=$this->usernameUsurpe)" )) { $this->usernameUsurpe = null; $success = false; Loading
src/UnicaenAuthentification/Options/ModuleOptions.php +10 −9 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace UnicaenAuthentification\Options; use BadMethodCallException; /** * Classe encapsulant les options de fonctionnement du module. * Loading Loading @@ -228,22 +230,21 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions } /** * @return string * @deprecated Méthode condamnée, utilisez explicitement ```getLdap()['username']``` */ public function getLdapUsername(): string { return $this->ldapUsername; return $this->getLdap()['username']; } /** * @param string $ldapUsername * @return self * @deprecated Cette méthode n'a plus de sens depuis l'abandon de la clé 'ldap_username' (devenue 'local.ldap.username') */ public function setLdapUsername(string $ldapUsername): self public function setLdapUsername(): self { $this->ldapUsername = $ldapUsername; return $this; throw new BadMethodCallException( "Cette méthode n'a plus de sens depuis l'abandon de la clé 'ldap_username' (devenue 'local.ldap.username')" ); } /** Loading Loading @@ -346,7 +347,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions { try { return parent::__get($key); } catch (\BadMethodCallException $e) { } catch (BadMethodCallException $e) { if (array_key_exists($key, $this->originalOptions)) { return $this->originalOptions[$key]; } else { Loading
src/UnicaenAuthentification/Options/ModuleOptionsFactory.php +17 −12 Original line number Diff line number Diff line Loading @@ -4,23 +4,22 @@ namespace UnicaenAuthentification\Options; use Assert\Assertion; use Assert\AssertionFailedException; use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; use UnicaenApp\Exception\RuntimeException; /** * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> */ class ModuleOptionsFactory class ModuleOptionsFactory implements FactoryInterface { protected $class = ModuleOptions::class; protected string $class = ModuleOptions::class; /** * Create service * * @param ContainerInterface $container * @return mixed * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container) public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $config = $container->get('Configuration'); $moduleConfig = $config['unicaen-auth'] ?? []; Loading @@ -31,10 +30,7 @@ class ModuleOptionsFactory return new $this->class($moduleConfig); } /** * @param array $config */ protected function validateConfig(array $config) protected function validateConfig(array $config): void { // // Config authentification shibboleth. Loading Loading @@ -81,5 +77,14 @@ class ModuleOptionsFactory "La clé de config 'unicaen-auth.$k' et son contenu doivent être déplacés sous la nouvelle clé 'unicaen-auth.local'" ); } // // Clé 'ldap_username' transformée. // if (array_key_exists($k = 'ldap_username', $config)) { throw new RuntimeException( "La clé de config 'unicaen-auth.$k' doit être supprimée et son contenu déplacé dans la nouvelle clé 'unicaen-auth.local.ldap.username'" ); } } } No newline at end of file