Skip to content
Snippets Groups Projects
Select Git revision
  • 3a73515cd62712cfcbccf69fd7ad3e0440f3f18c
  • master default protected
  • ll-workflow
  • alc-scindage-donnees-pj
  • b24
  • FJ_LL_Tbl_Contrat
  • alc-docker-node
  • ll-apiplatform
  • php84
  • ll-rgpd
  • b23
  • alc-filtre-type-intervenant
  • ll-sans-mdb5
  • formules-ancienne-infra
  • ll-formules
  • alc-intervenant-dmep
  • ll-suppr-v_vol-s
  • b20
  • ll-postgresql
  • b23.0.1
  • b22
  • 24.8
  • 24.7
  • 24.6
  • 24.5
  • 24.4
  • 24.3
  • 24.2
  • 24.1
  • 24.0
  • 23.15
  • 24.0-beta19
  • 24.0-beta18
  • 24.0-beta17
  • 24.0-beta16
  • 24.0-beta15
  • 24.0-beta14
  • 24.0-beta13
  • 23.14
  • 24.0-beta12
  • 24.0-beta11
41 results

NewEntityService.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    AuthController.php 9.05 KiB
    <?php
    
    namespace UnicaenAuth\Controller;
    
    use DomainException;
    use UnicaenApp\Controller\Plugin\AppInfos;
    use UnicaenApp\Controller\Plugin\Mail;
    use UnicaenApp\Exception\RuntimeException;
    use UnicaenAuth\Service\Traits\ShibServiceAwareTrait;
    use UnicaenAuth\Service\Traits\UserServiceAwareTrait;
    use Zend\Authentication\AuthenticationService;
    use Zend\Authentication\Exception\ExceptionInterface;
    use Zend\Http\Request;
    use Zend\Http\Response;
    use Zend\Mvc\Controller\AbstractActionController;
    use Zend\View\Model\ViewModel;
    use ZfcUser\Controller\Plugin\ZfcUserAuthentication;
    
    /**
     * Classe ajoutée lors de l'implémentation de l'auth Shibboleth.
     *
     * @method ZfcUserAuthentication zfcUserAuthentication()
     * @method AppInfos appInfos()
     * @method Mail mail()
     *
     * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
     */
    class AuthController extends AbstractActionController
    {
        use ShibServiceAwareTrait;
        use UserServiceAwareTrait;
    
        /**
         * Cette action peut être appelée lorsque l'authentification Shibboleth est activée
         * (unicaen-auth.shibboleth.enable === true).
         *
         * > Si la config Apache de Shibboleth est correcte, une requête à l'adresse correspondant à cette action
         * (suite au clic sur le bouton "Authentification Shibboleth", typiquement)
         * est détournée par Apache pour réaliser l'authentification Shibboleth.
         * Ce n'est qu'une fois l'authentification réalisée avec succès que cette action est appelée.
         *
         * > Si la config Apache de Shibboleth est incorrecte ou absente (localhost par exemple), et que la simulation
         * Shibboleth est activée dans la config (unicaen-auth.shibboleth.simulate), cette action est appelée et
         * la simulation est enclenchée.
         *
         * @return Response|array
         */
        public function shibbolethAction()
        {
            $operation = $this->params()->fromRoute('operation');
    
            if ($operation === 'deconnexion') {
                return $this->shibbolethLogout();
            }
    
            $redirectUrl = $this->params()->fromQuery('redirect', '/');
    
            // enclenchement de la simulation shibboleth éventuellement activée dans la config
            if ($simulate = $this->shibService->getShibbolethSimulate()) {
                $this->setStoredAuthenticatedUsername($simulate['eppn']); // tout simplement!
    
                return $this->redirect()->toUrl($redirectUrl);
            }
    
            $shibUser = $this->shibService->getAuthenticatedUser();
            if ($shibUser === null) {
                return []; // une page d'aide s'affichera si les données issues de Shibboleth attendues sont absentes
            }
    
            // arrivé ici, l'authentification shibboleth a été faite en bonne et due forme et a réussie.