Commit 30da9847 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Merge branch 'master' of git.unicaen.fr:dsi/sygal

parents ad67cc75 39a93ee0
Loading
Loading
Loading
Loading
+6 −9
Changes for config/autoload/unicaen-auth.global.php: 6 added lines, 9 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * UnicaenAuth Global Configuration
 *
 * If you have a ./config/autoload/ directory set up for your project, you can
 * drop this config file in it and change the values as you wish.
 */

use Application\Authentication\Storage\AppStorage;
@@ -67,12 +64,12 @@ $config = [
             * NB: si la connexion à la base échoue, ce n'est pas bloquant!
             */
            'UnicaenAuth\Provider\Role\DbRole'   => [],
            /**
             * Fournit le rôle correspondant à l'identifiant de connexion de l'utilisateur.
             * Cela est utile lorsque l'on veut gérer les habilitations d'un utilisateur unique
             * sur des ressources.
             */
            'UnicaenAuth\Provider\Role\Username' => [],
//            /**
//             * Fournit le rôle correspondant à l'identifiant de connexion de l'utilisateur.
//             * Cela est utile lorsque l'on veut gérer les habilitations d'un utilisateur unique
//             * sur des ressources.
//             */
//            'UnicaenAuth\Provider\Role\Username' => [],
        ],
    ],
    'zfcuser'      => [

error.log

0 → 100644
+6 −0
Changes for error.log: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line

1 /var/www/html/sygal-versions/sygal-20180313-123330/vendor/unicaen/app/src/UnicaenApp/Exporter/Pdf.php(371): UnicaenApp\\Exporter\\Pdf->getMpdf()\n
2 /var/www/html/sygal-versions/sygal-20180313-123330/vendor/unicaen/app/src/UnicaenApp/Exporter/Pdf.php(348): UnicaenApp\\Exporter\\Pdf->_addCss()\n
3 /var/www/html/sygal-versions/sygal-20180313-123330/vendor/unicaen/app/src/UnicaenApp/Exporter/Pdf.php(287): UnicaenApp\\Exporter\\Pdf->_generate()\n
4 /var/www/html/sygal-versions/sygal-20180313-123330/module/Application/src/Application/Service/These/PageDeGarde/PageDeCouverturePdfExporter.php(34): UnicaenApp\\Exporter\\Pdf->export('export.pdf', 'I', NULL)\n
5 /var/www/html/sygal-versions/sygal-201803 in /var/www/html/sygal-versions/sygal-20180313-123330/vendor/mpdf/mpdf/mpdf.php on line 1232, referer: https://sygal-pp.unicaen.fr/these/identite/28072
+1 −1
Changes for module/Application/config/module.config.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ use Application\Service\Role\RoleService;
use Application\Service\ServiceAwareInitializer;
use Application\Service\UserContextServiceAwareInitializer;
use Application\View\Helper\EscapeTextHelper;
use Application\View\Helper\QueryParamsHelperFactory;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use UnicaenApp\Service\EntityManagerAwareInitializer;
@@ -217,7 +218,6 @@ return array(
    ),
    'view_helpers' => array(
        'invokables' => array(
            'queryParams' => 'Application\View\Helper\QueryParams',
            'sortable'    => 'Application\View\Helper\Sortable',
            'Uploader'    => 'Application\View\Helper\Uploader\UploaderHelper',
            'filterPanel' => 'Application\View\Helper\FilterPanel\FilterPanelHelper',
+4 −1
Changes for module/Application/config/others/fichier.config.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

use Application\Command\CheckWSValidationFichierCinesCommandFactory;
use Application\Command\ValidationFichierCinesCommandFactory;
use Application\Controller\Factory\FichierControllerFactory;
use Application\Provider\Privilege\ThesePrivileges;
use Application\Provider\Privilege\ValidationPrivileges;
use Application\Service\Fichier\FichierServiceFactory;
@@ -198,9 +199,11 @@ return array(
    ),
    'controllers' => array(
        'invokables' => array(
            'Application\Controller\Fichier' => 'Application\Controller\FichierController',
            'Application\Controller\FichierThese' => 'Application\Controller\FichierTheseController',
        ),
        'factories' => [
            'Application\Controller\Fichier' => FichierControllerFactory::class,
        ]
    ),
    'controller_plugins' => [
        'invokables' => [
+50 −85
Changes for module/Application/src/Application/Authentication/Storage/AppStorage.php: 50 added lines, 85 removed lines.
Original line number Diff line number Diff line
@@ -3,16 +3,15 @@
namespace Application\Authentication\Storage;

use Application\Entity\Db\Doctorant;
use Application\Entity\Db\EcoleDoctoraleIndividu;
use Application\Entity\Db\UniteRechercheIndividu;
use Application\Entity\Db\Utilisateur;
use Application\Service\Doctorant\DoctorantServiceAwareTrait;
use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait;
use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait;
use Application\Service\Utilisateur\UtilisateurServiceAwareTrait;
use Doctrine\ORM\NonUniqueResultException;
use UnicaenApp\Entity\Ldap\People;
use UnicaenApp\Exception\RuntimeException;
use UnicaenAuth\Authentication\Storage\ChainableStorage;
use UnicaenAuth\Authentication\Storage\ChainEvent;
use UnicaenAuth\Entity\Ldap\People;
use UnicaenAuth\Entity\Shibboleth\ShibUser;
use Zend\Authentication\Exception\ExceptionInterface;

/**
@@ -22,25 +21,15 @@ use Zend\Authentication\Exception\ExceptionInterface;
 * - entité Doctorant si l'utilisateur authentifié est trouvé parmi les thésards,
 * - null sinon.
 *
 * Valeur associée à la clé KEY_ECOLE_DOCTORALE_INDIVIDU :
 * - entités EcoleDoctoraleIndividu si l'utilisateur authentifié est trouvé dans EcoleDoctoraleIndividu,
 * - [] sinon.
 *
 * Valeur associée à la clé KEY_UNITE_RECHERCHE_INDIVIDU :
 * - entités UniteRechercheIndividu si l'utilisateur authentifié est trouvé dans UniteRechercheIndividu,
 * - [] sinon.
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
  * @author Unicaen
 */
class AppStorage implements ChainableStorage
{
    use UtilisateurServiceAwareTrait;
    use DoctorantServiceAwareTrait;
    use EcoleDoctoraleServiceAwareTrait;
    use UniteRechercheServiceAwareTrait;

    const KEY_DB_UTILSATEUR = 'db';
    const KEY_DOCTORANT = 'doctorant';
    const KEY_ECOLE_DOCTORALE_INDIVIDU = 'ecoleDoctoraleIndividu';
    const KEY_UNITE_RECHERCHE_INDIVIDU = 'uniteRechercheIndividu';

    /**
     * @var mixed
@@ -53,49 +42,73 @@ class AppStorage implements ChainableStorage
    private $people;

    /**
     * @var Doctorant
     */
    protected $doctorant;

    /**
     * @var EcoleDoctoraleIndividu[]
     * @var ShibUser
     */
    protected $ecoleDoctoraleIndividu;
    private $shibUser;

    /**
     * @var UniteRechercheIndividu[]
     * @var Doctorant
     */
    protected $uniteRechercheIndividu;
    protected $doctorant;

    /**
     * @param ChainEvent $e
     * @return void
     * @throws \Zend\Authentication\Exception\ExceptionInterface
     */
    public function read(ChainEvent $e)
    {
        $this->contents = $e->getContents();

        $this->people = $this->contents['ldap'];
        $this->shibUser = $this->contents['shib'];

        if (null === $this->people && null === $this->shibUser) {
//            throw new RuntimeException("Aucune donnée d'authentification LDAP ni Shibboleth disponible");
            return;
        }

        /**
         * Recherche de l'utilisateur connecté dans la table Utilisateur.
         */
        $this->addDbUtilisateurContents($e);

        /**
         * Collecte des données au cas où l'utilisateur connecté est trouvé dans la table Doctorant.
         */
        $this->addDoctorantContents($e);
    }

    /**
         * Collecte des données au cas où l'utilisateur connecté est trouvé dans la table EcoleDoctoraleIndividu.
     * @param ChainEvent $e
     */
        $this->addEcoleDoctoraleIndividuContents($e);
    protected function addDbUtilisateurContents(ChainEvent $e)
    {
        try {
            $e->addContents(self::KEY_DB_UTILSATEUR, $this->fetchUtilisateur());
        } catch (ExceptionInterface $e) {
            throw new RuntimeException("Erreur imprévue rencontrée.", 0, $e);
        }
    }

    /**
         * Collecte des données au cas où l'utilisateur connecté est trouvé dans la table UniteRechercheIndividu.
     * @return null|Utilisateur
     */
        $this->addUniteRechercheIndividuContents($e);
    private function fetchUtilisateur()
    {
        if (null !== $this->people) {
            $username = $this->people->getSupannAliasLogin();
        } else {
            $username = $this->shibUser->getUsername();
        }

        /** @var Utilisateur $utilisateur */
        $utilisateur = $this->utilisateurService->getRepository()->findOneBy(['username' => $username]);

        return $utilisateur;
    }

    /**
     * @param ChainEvent $e
     * @return $this
     */
    protected function addDoctorantContents(ChainEvent $e)
    {
@@ -104,8 +117,6 @@ class AppStorage implements ChainableStorage
        } catch (ExceptionInterface $e) {
            throw new RuntimeException("Erreur imprévue rencontrée.", 0, $e);
        }

        return $this;
    }

    protected function fetchDoctorant()
@@ -119,7 +130,11 @@ class AppStorage implements ChainableStorage
         * - avec son numéro étudiant (Doctorant::sourceCode),
         * - avec son persopass (DoctorantCompl::persopass), seulement après qu'il l'a saisi sur la page d'identité de la thèse.
         */
        if (null !== $this->people) {
            $username = $this->people->getSupannAliasLogin();
        } else {
            $username = $this->shibUser->getUsername();
        }
        // todo: solution provisoire!
        $etablissement = 'UCN';
        try {
@@ -131,56 +146,6 @@ class AppStorage implements ChainableStorage
        return $this->doctorant;
    }

    private function addEcoleDoctoraleIndividuContents(ChainEvent $e)
    {
        try {
            $e->addContents(self::KEY_ECOLE_DOCTORALE_INDIVIDU, $this->fetchEcoleDoctoraleIndividu());
        } catch (ExceptionInterface $e) {
            throw new RuntimeException("Erreur imprévue rencontrée.", 0, $e);
        }

        return $this;
    }

    private function fetchEcoleDoctoraleIndividu()
    {
        if (null !== $this->ecoleDoctoraleIndividu) {
            return $this->ecoleDoctoraleIndividu;
        }

        $sourceCodeIndividu = $this->people->getSupannEmpId();

        $this->ecoleDoctoraleIndividu =
            $this->ecoleDoctoraleService->getRepository()->findMembresBySourceCodeIndividu($sourceCodeIndividu);

        return $this->ecoleDoctoraleIndividu;
    }

    private function addUniteRechercheIndividuContents(ChainEvent $e)
    {
        try {
            $e->addContents(self::KEY_UNITE_RECHERCHE_INDIVIDU, $this->fetchUniteRechercheIndividu());
        } catch (ExceptionInterface $e) {
            throw new RuntimeException("Erreur imprévue rencontrée.", 0, $e);
        }

        return $this;
    }

    private function fetchUniteRechercheIndividu()
    {
        if (null !== $this->uniteRechercheIndividu) {
            return $this->uniteRechercheIndividu;
        }

        $sourceCodeIndividu = $this->people->getSupannEmpId();

        $this->uniteRechercheIndividu =
            $this->uniteRechercheService->getRepository()->findMembresBySourceCodeIndividu($sourceCodeIndividu);

        return $this->uniteRechercheIndividu;
    }

    public function write(ChainEvent $e)
    {
        // nop
Loading