Skip to content
Snippets Groups Projects

Fix cas

Merged Bertrand Gauthier requested to merge fix-cas into master
1 file
+ 39
2
Compare changes
  • Side-by-side
  • Inline
<?php
<?php
 
namespace UnicaenAuth\Authentication\Adapter;
namespace UnicaenAuth\Authentication\Adapter;
use phpCAS;
use phpCAS;
use UnicaenApp\Exception;
use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper;
use UnicaenAuth\Options\ModuleOptions;
use UnicaenAuth\Options\ModuleOptions;
 
use UnicaenAuth\Service\User;
use Zend\Authentication\Exception\UnexpectedValueException;
use Zend\Authentication\Exception\UnexpectedValueException;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManager;
@@ -49,6 +51,11 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
@@ -49,6 +51,11 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
protected $casClient;
protected $casClient;
/**
/**
 
* @var LdapPeopleMapper
 
*/
 
protected $ldapPeopleMapper;
 
 
/**
* Réalise l'authentification.
* Réalise l'authentification.
*
*
* @param AuthEvent $e
* @param AuthEvent $e
@@ -94,7 +101,12 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
@@ -94,7 +101,12 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
$e->setCode(AuthenticationResult::SUCCESS)
$e->setCode(AuthenticationResult::SUCCESS)
->setMessages(['Authentication successful.']);
->setMessages(['Authentication successful.']);
$this->getEventManager()->trigger('userAuthenticated', $e);
// 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);
}
}
/**
/**
@@ -189,6 +201,31 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
@@ -189,6 +201,31 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
}
}
/**
/**
 
* 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
* Get service manager
*
*
* @return ServiceManager
* @return ServiceManager
Loading