Commit ef761bd8 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Meilleur contrôle des accès

ménage dans les routes
parent 134382c9
Loading
Loading
Loading
Loading
Loading
+106
Changes for code/Contrôle des guards.php: 106 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @var $this       \Application\View\Renderer\PhpRenderer
 * @var $container  \Psr\Container\ContainerInterface
 * @var $io         \Symfony\Component\Console\Style\SymfonyStyle
 */

$router = $container->get(\Unicaen\Framework\Router\Router::class);

$routes = $router->getRoutes();

$ok = [
    // divers
    "/ocra_service_manager_yuml",
    "/maintenance",
    "/icons",
    "/cache/js[/:version]",
    "/cache/css[/:version]",

    // unicaen/authentification
    "/auth",
    "/auth/creation-compte",
    "/auth/change-password",
    "/auth/change-email",
    "/utilisateur",
    "/utilisateur/:action[/:id]",

    // unicaen/import
    "/import",
    "/import/tableau-bord",
    "/import/maj-vues-fonctions",
    "/import/sources",
    "/import/sources/edition[/:source]",
    "/import/sources/suppression/:source",
    "/import/differentiel",
    "/import/tables/modifier/:table",
    "/import/tables/trier",
    "/import/tables/synchro-switch",
    "/import/tables/add-non-referenced",
    "/import/tables",
    "/import/differentiel/maj-vue-materialisee[/:table]",
    "/import/differentiel/synchronisation[/:table]",
    "/import/differentiel/details[/:table]",

    // unicaen/code
    "/unicaen-code[/:view]",

    // unicaen/signature
    "/signature/internal",
    "/signature/internal/visa/:key",
    "/signature/internal/document/:key",
    "/signature/process",

    // unicaen/siham
    "/siham",
];


$guards = $container->get(\Unicaen\Framework\Authorize\GuardProvider::class)->getAll();

foreach($routes as $route) {
    $controller = $route->getController();
    $action = $route->getAction();

    $privileges = $route->getPrivileges();

    if (in_array($route->getRoute(), $ok)){
        continue;
    }

    if (empty($controller)){
        // pas d'action derrière
        continue;
    }
    if (empty($action)){
        continue;
    }

    if (!empty($privileges)){
        // privileges OK
        continue;
    }

    $guard = $guards[$controller][$action] ?? null;
    $privileges = $guard?->privileges;

    if (!empty($privileges)){
        // privileges OK
        continue;
    }

    if (!empty($guard->roles)){
        continue;
    }
    if (!empty($guard->assertion)){
        continue;
    }

    echo '<h2>'.$route->getRoute().'</h2>';
    //$url = $this->url($route->getRoute());
    //echo $url;
    dump($controller.'.'.$action);
    dump($route);
    dump($guard);
}
 No newline at end of file
+2 −2
Changes for module/Dossier/config/module.config.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -176,8 +176,8 @@ return [
    'guards'       => [
        [
            'controller' => IntervenantDossierController::class,
            'action'     => ['index',
                             'change-statut-dossier'],
            'action'     => ['index', 'change-statut-dossier'],
            'privileges' => [Privileges::DOSSIER_VISUALISATION],
        ],

        [
−1
Changes for module/Dossier/src/Assertion/IntervenantDossierAssertion.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ namespace Dossier\Assertion;
use Application\Provider\Privileges;
use Dossier\Controller\IntervenantDossierController;
use Dossier\Entity\Db\IntervenantDossier;
use Dossier\Service\Traits\DossierServiceAwareTrait;
use Intervenant\Entity\Db\Intervenant;
use Unicaen\Framework\Authorize\AbstractAssertion;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
+9 −4
Changes for module/Enseignement/config/module.config.php: 9 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -35,19 +35,21 @@ return [
                    'child_routes'  => [
                        'enseignement' => [
                            'route'         => '/enseignement',
                            'controller'    => EnseignementController::class,
                            'may_terminate' => false,
                            'child_routes'  => [
                                'prevu'     => [
                                    'route'      => '/prevu',
                                    'controller' => EnseignementController::class,
                                    'action'     => 'validation-prevu',
                                ],
                                'realise'   => [
                                    'route'      => '/realise',
                                    'controller' => EnseignementController::class,
                                    'action'     => 'validation-realise',
                                ],
                                'valider'   => [
                                    'route'       => '/valider/:typeVolumeHoraire/:structure',
                                    'controller'  => EnseignementController::class,
                                    'action'      => 'valider',
                                    'constraints' => [
                                        'typeVolumeHoraire' => '[0-9]*',
@@ -56,6 +58,7 @@ return [
                                ],
                                'devalider' => [
                                    'route'       => '/devalider/:validation',
                                    'controller'  => EnseignementController::class,
                                    'action'      => 'devalider',
                                    'constraints' => [
                                        'validation' => '[0-9]*',
@@ -130,15 +133,14 @@ return [

        'volume-horaire' => [
            'route'         => '/volume-horaire',
            'controller'    => VolumeHoraireController::class,
            'action'        => 'index',
            'may_terminate' => true,
            'may_terminate' => false,
            'child_routes'  => [
                'liste'                  => [
                    'route'       => '/liste[/:service]',
                    'constraints' => [
                        'service' => '[0-9]*',
                    ],
                    'controller'  => VolumeHoraireController::class,
                    'action'      => 'liste',
                ],
                'saisie'                 => [
@@ -146,6 +148,7 @@ return [
                    'constraints' => [
                        'service' => '[0-9]*',
                    ],
                    'controller'  => VolumeHoraireController::class,
                    'action'      => 'saisie',
                ],
                'saisie-calendaire'      => [
@@ -153,6 +156,7 @@ return [
                    'constraints' => [
                        'service' => '[0-9]*',
                    ],
                    'controller'  => VolumeHoraireController::class,
                    'action'      => 'saisie-calendaire',
                ],
                'suppression-calendaire' => [
@@ -160,6 +164,7 @@ return [
                    'constraints' => [
                        'service' => '[0-9]*',
                    ],
                    'controller'  => VolumeHoraireController::class,
                    'action'      => 'suppression-calendaire',
                ],
            ],
−5
Changes for module/Intervenant/config/intervenant.config.php: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -98,11 +98,6 @@ return [
                    'controller' => Controller\IntervenantController::class,
                    'action'     => 'definir-par-defaut',
                ],
                'feuille-de-route'   => [
                    'route'      => '/:intervenant/feuille-de-route',
                    'controller' => Controller\IntervenantController::class,
                    'action'     => 'feuille-de-route',
                ],
            ],
        ],
    ],
Loading