From c27761cb7c900cd457eb2bdb0c82006eaaf118aa Mon Sep 17 00:00:00 2001 From: Bertrand Gauthier <bertrand.gauthier@unicaen.fr> Date: Wed, 10 Apr 2019 11:54:42 +0200 Subject: [PATCH] =?UTF-8?q?ShibService=20:=20correction=20n=C3=A9cessaire?= =?UTF-8?q?=20pour=20tester=20si=20un=20utilisateur=20est=20authentifi?= =?UTF-8?q?=C3=A9=20ou=20non.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UnicaenAuth/Service/ShibService.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/UnicaenAuth/Service/ShibService.php b/src/UnicaenAuth/Service/ShibService.php index d78ffa7..7d9d488 100644 --- a/src/UnicaenAuth/Service/ShibService.php +++ b/src/UnicaenAuth/Service/ShibService.php @@ -85,12 +85,24 @@ EOS; // ENSUITE activation éventuelle de l'usurpation $this->handleUsurpation(); + if (! $this->isAuthenticated()) { + return null; + } + $this->authenticatedUser = $this->createShibUserFromServerArrayData(); } return $this->authenticatedUser; } + /** + * @return bool + */ + private function isAuthenticated() + { + return (bool) $this->getServerArrayVariable('REMOTE_USER'); + } + /** * @return boolean */ @@ -351,6 +363,9 @@ EOS; */ public function simulateAuthenticatedUser(ShibUser $shibUser, $keyForId = 'supannEmpId') { + // 'REMOTE_USER' est utilisé pour savoir si un utilisateur est authentifié ou non + $this->setServerArrayVariable('REMOTE_USER', $shibUser->getEppn()); + // // on s'assure que tous les attributs obligatoires ont une valeur // foreach ($this->getShibbolethRequiredAttributes() as $requiredAttribute) { // // un pipe permet d'exprimer un OU logique, ex: 'supannEmpId|supannEtuId' @@ -452,8 +467,8 @@ EOS; 'options' => [ 'route' => '/connexion', 'defaults' => [ - 'controller' => 'zfcuser', // NB: lorsque l'auth Shibboleth est activée, la page propose - 'action' => 'login', // 2 possibilités d'auth : LDAP et Shibboleth. + 'controller' => 'zfcuser', + 'action' => 'login', ], ], ], -- GitLab