Loading code/test3.php +3 −8 Original line number Diff line number Diff line Loading @@ -8,14 +8,9 @@ echo '<br /><br /><br /><br /><br /><br /><br />'; $um = $container->get(\Framework\User\UserManager::class); $um->updatePrivileges(); dump($um->getPrivileges()); $p = $container->get(\Framework\Authorize\RuleProvider::class); $d = $p->getAll(); dump($d); $a = $container->get(\Laminas\Authentication\AuthenticationService::class); $c = $a->getIdentity(); dump($c); No newline at end of file config/modules.config.php +1 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Framework\Application\Application; $config = Application::getInstance()->config(); $modules = [ 'Laminas\Filter', 'Laminas\Form', 'Laminas\Hydrator', Loading @@ -17,7 +18,6 @@ $modules = [ 'Laminas\Router', 'Laminas\Session', 'Laminas\Validator', 'BjyAuthorize', 'DoctrineModule', 'DoctrineORMModule', 'ZfcUser', Loading module/Administration/config/administration.config.php +1 −1 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ $config = [ [ 'controller' => Controller\AdministrationController::class, 'action' => ['rubrique'], 'roles' => 'user', 'privileges' => 'user', ], ], Loading module/Administration/src/Assertion/GestionAssertion.php +8 −24 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Administration\Assertion; use Application\Service\Traits\ContextServiceAwareTrait; use Framework\Authorize\AbstractAssertion; use Utilisateur\Acl\Role; Loading @@ -13,36 +14,19 @@ use Utilisateur\Acl\Role; */ class GestionAssertion extends AbstractAssertion { /** * @var boolean[] */ protected $cache=[]; use ContextServiceAwareTrait; protected function assertController($controller, $action = null, $privilege = null): bool { $role = $this->getRole(); $key = $controller.'.'.$action.'>'.$privilege; if (!isset($this->cache[$key])){ $this->cache[$key] = $this->asserts([ $role instanceof Role, $this->assertIntervenant($role, $privilege) ]); if ($privilege && !$this->authorize->isAllowedPrivilege($privilege)) { return false; } return $this->cache[$key]; } protected function assertIntervenant( Role $role, $privilege ): bool { return $this->asserts([ !$privilege || $role->hasPrivilege($privilege), // pareil si le rôle ne possède pas le privilège adéquat !$role->getIntervenant() // les intervenants n'ont pour le moment pas accès au menu Gestion ]); if ($this->getServiceContext()->getIntervenant()) { return false; } return true; } } No newline at end of file module/Administration/src/Controller/AdministrationController.php +13 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Administration\Controller; use Application\Controller\AbstractController; use Framework\Navigation\Navigation; /** * Description of AdministrationController Loading @@ -14,16 +15,26 @@ use Application\Controller\AbstractController; class AdministrationController extends AbstractController { public function __construct( private readonly Navigation $navigation ) { } public function indexAction() { return []; $pages = $this->navigation->getCurrentPage()->getVisiblePages(); return compact('pages'); } public function rubriqueAction() { return []; $pages = $this->navigation->getCurrentPage()->getVisiblePages(); return compact('pages'); } } No newline at end of file Loading
code/test3.php +3 −8 Original line number Diff line number Diff line Loading @@ -8,14 +8,9 @@ echo '<br /><br /><br /><br /><br /><br /><br />'; $um = $container->get(\Framework\User\UserManager::class); $um->updatePrivileges(); dump($um->getPrivileges()); $p = $container->get(\Framework\Authorize\RuleProvider::class); $d = $p->getAll(); dump($d); $a = $container->get(\Laminas\Authentication\AuthenticationService::class); $c = $a->getIdentity(); dump($c); No newline at end of file
config/modules.config.php +1 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Framework\Application\Application; $config = Application::getInstance()->config(); $modules = [ 'Laminas\Filter', 'Laminas\Form', 'Laminas\Hydrator', Loading @@ -17,7 +18,6 @@ $modules = [ 'Laminas\Router', 'Laminas\Session', 'Laminas\Validator', 'BjyAuthorize', 'DoctrineModule', 'DoctrineORMModule', 'ZfcUser', Loading
module/Administration/config/administration.config.php +1 −1 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ $config = [ [ 'controller' => Controller\AdministrationController::class, 'action' => ['rubrique'], 'roles' => 'user', 'privileges' => 'user', ], ], Loading
module/Administration/src/Assertion/GestionAssertion.php +8 −24 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Administration\Assertion; use Application\Service\Traits\ContextServiceAwareTrait; use Framework\Authorize\AbstractAssertion; use Utilisateur\Acl\Role; Loading @@ -13,36 +14,19 @@ use Utilisateur\Acl\Role; */ class GestionAssertion extends AbstractAssertion { /** * @var boolean[] */ protected $cache=[]; use ContextServiceAwareTrait; protected function assertController($controller, $action = null, $privilege = null): bool { $role = $this->getRole(); $key = $controller.'.'.$action.'>'.$privilege; if (!isset($this->cache[$key])){ $this->cache[$key] = $this->asserts([ $role instanceof Role, $this->assertIntervenant($role, $privilege) ]); if ($privilege && !$this->authorize->isAllowedPrivilege($privilege)) { return false; } return $this->cache[$key]; } protected function assertIntervenant( Role $role, $privilege ): bool { return $this->asserts([ !$privilege || $role->hasPrivilege($privilege), // pareil si le rôle ne possède pas le privilège adéquat !$role->getIntervenant() // les intervenants n'ont pour le moment pas accès au menu Gestion ]); if ($this->getServiceContext()->getIntervenant()) { return false; } return true; } } No newline at end of file
module/Administration/src/Controller/AdministrationController.php +13 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Administration\Controller; use Application\Controller\AbstractController; use Framework\Navigation\Navigation; /** * Description of AdministrationController Loading @@ -14,16 +15,26 @@ use Application\Controller\AbstractController; class AdministrationController extends AbstractController { public function __construct( private readonly Navigation $navigation ) { } public function indexAction() { return []; $pages = $this->navigation->getCurrentPage()->getVisiblePages(); return compact('pages'); } public function rubriqueAction() { return []; $pages = $this->navigation->getCurrentPage()->getVisiblePages(); return compact('pages'); } } No newline at end of file