Skip to content
Snippets Groups Projects
Commit ccb95308 authored by David Surville's avatar David Surville
Browse files

Quelques corrections nécessaires après l'intégration de la branche...

Quelques corrections nécessaires après l'intégration de la branche release/1.3.0 dans la branche 5.x
parent f62c8de3
No related branches found
No related tags found
No related merge requests found
Pipeline #24939 passed
...@@ -18,12 +18,6 @@ use ZfcUser\Entity\UserInterface; ...@@ -18,12 +18,6 @@ use ZfcUser\Entity\UserInterface;
*/ */
class Ldap extends AuthenticationIdentityProvider implements ChainableProvider class Ldap extends AuthenticationIdentityProvider implements ChainableProvider
{ {
protected $usernamefield;
public function setUsernamefield(?string $value = null)
{
$this->usernamefield=$value;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
...@@ -56,7 +50,7 @@ class Ldap extends AuthenticationIdentityProvider implements ChainableProvider ...@@ -56,7 +50,7 @@ class Ldap extends AuthenticationIdentityProvider implements ChainableProvider
} }
if ($identity instanceof UserInterface) { if ($identity instanceof UserInterface) {
$roles[] = $identity->getUsername($this->usernamefield); $roles[] = $identity->getUsername();
} }
return $roles; return $roles;
......
...@@ -31,9 +31,6 @@ class LdapServiceFactory implements FactoryInterface ...@@ -31,9 +31,6 @@ class LdapServiceFactory implements FactoryInterface
$simpleIdentityProvider->setDefaultRole($config['default_role']); $simpleIdentityProvider->setDefaultRole($config['default_role']);
$simpleIdentityProvider->setAuthenticatedRole($config['authenticated_role']); $simpleIdentityProvider->setAuthenticatedRole($config['authenticated_role']);
$usernamefield = $container->get('Config')['unicaen-auth']['local']['ldap']['username'];
$simpleIdentityProvider->setUsernamefield($usernamefield);
return $simpleIdentityProvider; return $simpleIdentityProvider;
} }
} }
\ No newline at end of file
...@@ -138,7 +138,7 @@ class UserContext extends AbstractService implements EventManagerAwareInterface ...@@ -138,7 +138,7 @@ class UserContext extends AbstractService implements EventManagerAwareInterface
return $user->getUsername(); return $user->getUsername();
} }
if ($user = $this->getLdapUser()) { if ($user = $this->getLdapUser()) {
return $user->getUsername($this->usernamefield); return $user->getUsername();
} }
if ($user = $this->getDbUser()) { if ($user = $this->getDbUser()) {
return $user->getUsername(); return $user->getUsername();
......
...@@ -32,8 +32,7 @@ class UserContextFactory ...@@ -32,8 +32,7 @@ class UserContextFactory
// mais c'est impossible pour l'instant car il y a un cycle dans les dépendances entre services qui // mais c'est impossible pour l'instant car il y a un cycle dans les dépendances entre services qui
// provoque une boucle infinie. // provoque une boucle infinie.
// //
$usernamefield = $container->get('Config')['unicaen-auth']['local']['ldap']['username'];
$service->setUsernamefield($usernamefield);
return $service; return $service;
} }
} }
\ No newline at end of file
...@@ -90,21 +90,4 @@ class UserMapper implements UserInterface ...@@ -90,21 +90,4 @@ class UserMapper implements UserInterface
return $entity; return $entity;
} }
//===================
/**
* Recherche un utilisateur par son username (identifiant de connexion).
*
* @param string $username
* @return AbstractUser|null
*/
public function findOneByUsername($username)
{
/** @var AbstractUser $user */
$user = $this->em->getRepository($this->options->getUserEntityClass())->findOneBy(['username' => $username]);
return $user;
}
} }
\ No newline at end of file
...@@ -11,8 +11,6 @@ use UnicaenUtilisateur\View\Helper\UserAbstract; ...@@ -11,8 +11,6 @@ use UnicaenUtilisateur\View\Helper\UserAbstract;
*/ */
class UserConnection extends UserAbstract class UserConnection extends UserAbstract
{ {
public bool $onlyCas = false;
/** /**
* Point d'entrée. * Point d'entrée.
* *
...@@ -20,6 +18,7 @@ class UserConnection extends UserAbstract ...@@ -20,6 +18,7 @@ class UserConnection extends UserAbstract
*/ */
public function __invoke() public function __invoke()
{ {
return $this;
} }
/** /**
...@@ -35,13 +34,6 @@ class UserConnection extends UserAbstract ...@@ -35,13 +34,6 @@ class UserConnection extends UserAbstract
return $out; return $out;
} }
public function computeConnectionLink()
{
$urlHelper = $this->getView()->plugin('url');
$href = $urlHelper('zfcuser/login');
if ($this->onlyCas) $href = $urlHelper('zfcuser/authenticate',['type' => 'cas']);
return $href;
}
/** /**
* *
* @return string * @return string
...@@ -54,7 +46,7 @@ class UserConnection extends UserAbstract ...@@ -54,7 +46,7 @@ class UserConnection extends UserAbstract
$template = '<a class="navbar-link user-connection" href="%s" title="%s">%s</a>'; $template = '<a class="navbar-link user-connection" href="%s" title="%s">%s</a>';
if (!$identity) { if (!$identity) {
$href = $this->computeConnectionLink(); $href = $urlHelper('zfcuser/login');
$lib = "Connexion"; $lib = "Connexion";
$title = "Affiche le formulaire d'authentification"; $title = "Affiche le formulaire d'authentification";
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
namespace UnicaenAuthentification\View\Helper; namespace UnicaenAuthentification\View\Helper;
use Psr\Container\ContainerInterface;
use Laminas\ServiceManager\FactoryInterface; use Laminas\ServiceManager\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface; use Laminas\ServiceManager\ServiceLocatorInterface;
use Psr\Container\ContainerInterface;
/** /**
* Description of UserConnectionFactory * Description of UserConnectionFactory
...@@ -20,17 +20,8 @@ class UserConnectionFactory implements FactoryInterface ...@@ -20,17 +20,8 @@ class UserConnectionFactory implements FactoryInterface
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{ {
$config = $container->get('Config')['unicaen-auth'];
$activeModes = [];
foreach ($config['auth_types'] as $type) {
if ($config[$type]['enabled']) $activeModes[] = $type;
}
$onlyCas = (count($activeModes) === 1 AND $activeModes[0] === 'cas');
$authUserContext = $container->get('authUserContext'); $authUserContext = $container->get('authUserContext');
$uc = new UserConnection($authUserContext); return new UserConnection($authUserContext);
$uc->onlyCas = $onlyCas;
return $uc;
} }
} }
\ No newline at end of file
<?php <?php
use Application\View\Renderer\PhpRenderer;
use UnicaenAuthentification\Form\LoginForm;
use Laminas\Form\Form;
/** /**
* @var PhpRenderer $this * @var PhpRenderer $this
* @var array[] $types Types d'authentification activés, ex: ['db' => ['enabled'=>true, 'type'=>'local'], 'shib' => ['enabled'=>true]] * @var array[] $types Types d'authentification activés, ex: ['db' => ['enabled'=>true, 'type'=>'local'], 'shib' => ['enabled'=>true]]
...@@ -11,10 +16,6 @@ ...@@ -11,10 +16,6 @@
* @see \UnicaenAuthentification\Controller\AuthController::loginAction() * @see \UnicaenAuthentification\Controller\AuthController::loginAction()
*/ */
use Application\View\Renderer\PhpRenderer;
use UnicaenAuthentification\Form\LoginForm;
use Laminas\Form\Form;
$this->headTitle("Connexion") ?> $this->headTitle("Connexion") ?>
<div class="div-connexion"> <div class="div-connexion">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment