Commit a6de64b4 authored by David Surville's avatar David Surville
Browse files

Merge branch 'release/8.0-perimetres'

parents 445b7c74 46d399a8
Loading
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
Journal des modifications
=========================

7.0.0 (02/12/2025)
------------------

- Intégration des périmètres
- Revue des pages de gestion des privilèges

6.3.0 (04/09/2025)
------------------

6.3.0
-----
- Possibilité d'activer la mise en cache du tableau des rôles par privilège pour accélerer l'init du moteur d'ACL
  (cf. [migration.md](doc/migration.md#630)).

6.0.5 (19/12/2023)
------------------

- [Fix] Un seul privilège peut être transmis sous forme de string à convertir en array 

6.0.1 (21/03/2023)
-----
------------------

- Mise en place du changelog
- Réintégration de l'AssertionFactory, à utiliser pour les assertions
- [Fix] erreur ns \InvalidArgumentException : \ ajouté

5.0.7 (05/05/2023)
-----
------------------

- Correction bug d'affichage sur le tableau d'affectation lorsque deux catégories possèdent le même libellé
+2 −2
Original line number Diff line number Diff line
{
    "name": "unicaen/privilege",
    "description": "Module reprenant la gestion des privileges  - Version laminas",
    "description": "Module reprenant la gestion des privileges",
    "repositories": [
        {
            "type": "composer",
@@ -11,7 +11,7 @@
        "laminas/laminas-cache": "^3.13",
        "laminas/laminas-cache-storage-adapter-filesystem": "^2.5",
        "unicaen/app": ">=5.0",
	    "unicaen/utilisateur": ">=6.2"
	    "unicaen/utilisateur": "dev-release/8.0-perimetres"
    },
    "require-dev": {
        "laminas/laminas-cli": "^1.11",
+264 −0
Original line number Diff line number Diff line
<?php

use UnicaenPrivilege\Assertion\Perimetre\AbstractPerimetreAssertionFactory;
use UnicaenPrivilege\Controller\PerimetreCategorieController;
use UnicaenPrivilege\Controller\PerimetreCategorieControllerFactory;
use UnicaenPrivilege\Controller\PerimetreController;
use UnicaenPrivilege\Controller\PerimetreControllerFactory;
use UnicaenPrivilege\Form\Perimetre\CategorieForm;
use UnicaenPrivilege\Form\Perimetre\CategorieFormFactory;
use UnicaenPrivilege\Form\Perimetre\PerimetreForm;
use UnicaenPrivilege\Form\Perimetre\PerimetreFormFactory;
use UnicaenPrivilege\Provider\Privilege\PerimetrePrivileges;
use UnicaenPrivilege\Service\Perimetre\PerimetreCategorieService;
use UnicaenPrivilege\Service\Perimetre\PerimetreCategorieServiceFactory;
use UnicaenPrivilege\Service\Perimetre\PerimetreService;
use UnicaenPrivilege\Service\Perimetre\PerimetreServiceFactory;
use UnicaenPrivilege\View\Helper\Perimetre\PerimetreCategorieViewHelper;

return [
    'bjyauthorize' => [
        'guards' => [
            UnicaenPrivilege\Guard\PrivilegeController::class => [
                [
                    'controller' => PerimetreController::class,
                    'action' => [
                        'index',
                    ],
                    'privileges' => [
                        PerimetrePrivileges::CONSULTER,
                    ],
                ],
                [
                    'controller' => PerimetreController::class,
                    'action' => [
                        'ajouter',
                        'modifier'
                    ],
                    'privileges' => [
                        PerimetrePrivileges::EDITER,
                    ],
                ],
                [
                    'controller' => PerimetreController::class,
                    'action' => [
                        'supprimer',
                    ],
                    'privileges' => [
                        PerimetrePrivileges::SUPPRIMER,
                    ],
                ],
                [
                    'controller' => PerimetreCategorieController::class,
                    'action' => [
                        'index',
                        'gerer',
                    ],
                    'privileges' => [
                        PerimetrePrivileges::CONSULTER,
                    ],
                ],
                [
                    'controller' => PerimetreCategorieController::class,
                    'action' => [
                        'activer',
                    ],
                    'privileges' => [
                        PerimetrePrivileges::ATTRIBUER,
                    ],
                ],
                [
                    'controller' => PerimetreCategorieController::class,
                    'action' => [
                        'ajouter',
                        'modifier',
                    ],
                    'privileges' => [
                        PerimetrePrivileges::EDITER,
                    ],
                ],
                [
                    'controller' => PerimetreCategorieController::class,
                    'action' => [
                        'supprimer',
                    ],
                    'privileges' => [
                        PerimetrePrivileges::SUPPRIMER,
                    ],
                ],
            ],
        ],
    ],

    'router' => [
        'routes' => [
            'unicaen-perimetre' => [
                'type' => Literal::class,
                'options' => [
                    'route' => '/perimetre',
                    'defaults' => [
                        'controller' => PerimetreController::class,
                        'action' => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'ajouter' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/ajouter/:categorie',
                            'defaults' => [
                                'controller' => PerimetreController::class,
                                'action' => 'ajouter',
                            ],
                            'constraints' => [
                                'categorie' => '\d+',
                            ],
                        ],
                    ],
                    'modifier' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/modifier/:perimetre',
                            'defaults' => [
                                'controller' => PerimetreController::class,
                                'action' => 'modifier',
                            ],
                            'constraints' => [
                                'perimetre' => '\d+',
                            ],
                        ],
                    ],
                    'supprimer' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/supprimer/:perimetre',
                            'defaults' => [
                                'controller' => PerimetreController::class,
                                'action' => 'supprimer',
                            ],
                            'constraints' => [
                                'perimetre' => '\d+',
                            ],
                        ],
                    ],
                    'categorie' => [
                        'type' => Literal::class,
                        'options' => [
                            'route' => '/categorie',
                            'defaults' => [
                                'controller' => PerimetreCategorieController::class,
                                'action' => 'index',
                            ],
                        ],
                        'may_terminate' => true,
                        'child_routes' => [
                            'activer' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/activer/:role/:categorie',
                                    'defaults' => [
                                        'controller' => PerimetreCategorieController::class,
                                        'action' => 'activer',
                                    ],
                                    'constraints' => [
                                        'role' => '\d+',
                                        'categorie' => '\d+',
                                    ],
                                ],
                            ],
                            'ajouter' => [
                                'type' => Literal::class,
                                'options' => [
                                    'route' => '/ajouter',
                                    'defaults' => [
                                        'controller' => PerimetreCategorieController::class,
                                        'action' => 'ajouter',
                                    ],
                                ],
                            ],
                            'gerer' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/gerer/:categorie',
                                    'defaults' => [
                                        'controller' => PerimetreCategorieController::class,
                                        'action' => 'gerer',
                                    ],
                                    'constraints' => [
                                        'categorie' => '\d+',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
                            'modifier' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/modifier/:categorie',
                                    'defaults' => [
                                        'controller' => PerimetreCategorieController::class,
                                        'action' => 'modifier',
                                    ],
                                    'constraints' => [
                                        'categorie' => '\d+',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
                            'supprimer' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/supprimer/:categorie',
                                    'defaults' => [
                                        'controller' => PerimetreCategorieController::class,
                                        'action' => 'supprimer',
                                    ],
                                    'constraints' => [
                                        'categorie' => '\d+',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'controllers' => [
        'factories' => [
            PerimetreCategorieController::class => PerimetreCategorieControllerFactory::class,
            PerimetreController::class => PerimetreControllerFactory::class,
        ],
    ],

    'service_manager' => [
        'factories' => [
            PerimetreCategorieService::class => PerimetreCategorieServiceFactory::class,
            PerimetreService::class => PerimetreServiceFactory::class,
        ],
        'abstract_factories' => [
            AbstractPerimetreAssertionFactory::class,
        ],
    ],

    'form_elements' => [
        'factories' => [
            CategorieForm::class => CategorieFormFactory::class,
            PerimetreForm::class => PerimetreFormFactory::class,
        ],
    ],

    'hydrators' => [
        'invokables' => [
            'perimetre' => PerimetreViewHelper::class,
        ],
    ],

    'view_helpers' => [
        'invokables' => [
            'perimetreCategorie' => PerimetreCategorieViewHelper::class,
        ],
    ],
];
+32 −7
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieService;
use UnicaenPrivilege\Service\Privilege\PrivilegeCategorieServiceFactory;
use UnicaenPrivilege\Service\Privilege\PrivilegeService;
use UnicaenPrivilege\Service\Privilege\PrivilegeServiceFactory;
use UnicaenPrivilege\View\Privilege\PrivilegeViewHelper;
use UnicaenPrivilege\View\Helper\Privilege\PrivilegeViewHelper;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;

@@ -128,23 +128,30 @@ return [
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'attribuer' => [
                    'ajouter' => [
                        'type' => Segment::class,
                        'options' => [
                            'route'    => '/attribuer/:role/:privilege',
                            'route' => '/ajouter/:categorie',
                            'defaults' => [
                                'controller' => PrivilegeController::class,
                                'action' => 'attribuer',
                                'action' => 'ajouter',
                            ],
                            'constraints' => [
                                'categorie' => '\d+',
                            ],
                        ],
                    'ajouter' => [
                    ],
                    'attribuer' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/ajouter/:categorie',
                            'route'    => '/attribuer/:role/:privilege',
                            'defaults' => [
                                'controller' => PrivilegeController::class,
                                'action' => 'ajouter',
                                'action' => 'attribuer',
                            ],
                            'constraints' => [
                                'role' => '\d+',
                                'privilege' => '\d+',
                            ],
                        ],
                    ],
@@ -156,6 +163,9 @@ return [
                                'controller' => PrivilegeController::class,
                                'action' => 'modifier',
                            ],
                            'constraints' => [
                                'privilege' => '\d+',
                            ],
                        ],
                    ],
                    'supprimer' => [
@@ -166,6 +176,9 @@ return [
                                'controller' => PrivilegeController::class,
                                'action' => 'supprimer',
                            ],
                            'constraints' => [
                                'privilege' => '\d+',
                            ],
                        ],
                    ],
                    'categorie' => [
@@ -197,6 +210,9 @@ return [
                                        'controller' => PrivilegeCategorieController::class,
                                        'action'     => 'gerer',
                                    ],
                                    'constraints' => [
                                        'categorie' => '\d+',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
@@ -208,6 +224,9 @@ return [
                                        'controller' => PrivilegeCategorieController::class,
                                        'action'     => 'provider',
                                    ],
                                    'constraints' => [
                                        'categorie' => '\d+',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
@@ -219,6 +238,9 @@ return [
                                        'controller' => PrivilegeCategorieController::class,
                                        'action'     => 'modifier',
                                    ],
                                    'constraints' => [
                                        'categorie' => '\d+',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
@@ -230,6 +252,9 @@ return [
                                        'controller' => PrivilegeCategorieController::class,
                                        'action'     => 'supprimer',
                                    ],
                                    'constraints' => [
                                        'categorie' => '\d+',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
+73 −0
Original line number Diff line number Diff line
<?php

use UnicaenPrivilege\Entity\Db\Perimetre;
use UnicaenPrivilege\Provider\Privilege\PerimetrePrivileges;


$settings = [
    'unicaen-auth' => [
        'enable_perimetres' => false,
    ],
];

if ($settings['unicaen-auth']['enable_perimetres']) {
    $perimetres = [
        'unicaen-auth' => [
            /**
             * L'entité associée aux périmètres peut être spécifiée via la clef de configuration ['unicaen_auth']['perimetre_entity_class']
             * Si elle est manquante alors la classe @see \UnicaenPrivilege\Entity\Db\Perimetre est utilisée
             * NB: la classe spécifiée doit hériter de @see \UnicaenPrivilege\Entity\Db\AbstractPerimetre
             */
            'perimetre_entity_class' => Perimetre::class,
        ],

        'unicaen-perimetre' => [
            /**
             * Liste des assertions utilisées et des services associés.
             *
             * Important :
             * - le nom de l'assertion au niveau des routes doit respecter le format 'Perimetre\\<nom_de_l_assertion>' (ex : 'assertion' => 'Perimetre\\Structure')
             * - le service associé doit hériter de @see \UnicaenPrivilege\Assertion\Perimetre\AbstractPerimetreAssertion
             */
            'assertions' => [
                /** Exemple :
                 * 'Structure' => StructureAssertion::class,
                 */
            ],
        ],

        'navigation' => [
            'default' => [
                'home' => [
                    'pages' => [
                        // Pour les anciennes applications qui avaient besoin de la route "droits"
                        'droits' => [
                            'label' => "Droits",
                            'title' => "Droits",
                            'route' => 'unicaen-perimetre',
                            'visible' => false,
                        ],
                        // Pour les nouvelles applications qui utilisent la route "administration"
                        'administration' => [
                            'label' => "Administration",
                            'title' => "Administration",
                            'route' => "unicaen-perimetre",
                            'pages' => [
                                [
                                    'label' => "Gérer les périmètres",
                                    'title' => "Gérer les périmètres",
                                    'route' => 'unicaen-perimetre',
                                    'resource' => PerimetrePrivileges::getResourceId(PerimetrePrivileges::CONSULTER),
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ];
} else {
    $perimetres = [];
}

return array_merge_recursive($settings, $perimetres);
 No newline at end of file
Loading