Commit 28117e45 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

WIP kill bjyauthorize

parent cbb57830
Loading
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ use Framework\Application\Application;
$config = Application::getInstance()->config();

$modules = [

    'Laminas\Filter',
    'Laminas\Form',
    'Laminas\Hydrator',
@@ -17,7 +18,6 @@ $modules = [
    'Laminas\Router',
    'Laminas\Session',
    'Laminas\Validator',
    'BjyAuthorize',
    'DoctrineModule',
    'DoctrineORMModule',
    'ZfcUser',
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ $config = [
        [
            'controller' => Controller\AdministrationController::class,
            'action'     => ['rubrique'],
            'roles'      => 'user',
            'privileges' => 'user',
        ],
    ],

+8 −24
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Administration\Assertion;

use Application\Service\Traits\ContextServiceAwareTrait;
use Framework\Authorize\AbstractAssertion;
use Utilisateur\Acl\Role;

@@ -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
+13 −2
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Administration\Controller;


use Application\Controller\AbstractController;
use Framework\Navigation\Navigation;

/**
 * Description of AdministrationController
@@ -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