Where should I define ACL for Pages?

Hi.

When I create navigation, I can happily use a ready-made factory to use a configuration file like as follow.

    'navigation' => [
        'default' => [
            [
                'label' => 'HOME',
                'controller' => 'home',
                'action' => 'index',
                'resource' => 'guest',
            ],...

But when I create ACL, I can’t find a ready-made factory for ACL using such a
configuration file as follows.

'acl' =>[
        'roles' => [
            'guest'          =>  [],
            'user'            =>  ['guest'],
            'admin'    =>  ['user'],
        ],
        'resources' => [
            'admin.action',
            'user.action',
            'guest.action',
            'login.action'
        ],

If so, I have to define ACL myself somewhere.

The “navigation helper factory” or the “despatch event listener” comes to my mind.

Where should I define ACL for Pages?

Unfortunately, there is no factory in the laminas-permissions-acl component at the moment, but it is planned.
But you can adopt the configuration from mezzio-authorization-acl:

The you can copy and modify the factory:

And to set the ACL for the navigation helpers, you can use this delegator:

1 Like

guest is not a resource, but a role. According your ACL configuration, you have to use guest.action or something similar.

1 Like

Thank you for your suggestion again.

Thanks to your help, the base of our project are almost complete :fist:

Humm, when we start new project, should we use Mezzio rather than MVC?

Oh, I found a document.
https://docs.mezzio.dev/mezzio/v3/why-mezzio/

I’ll read it.


I like Laminas because it doesn’t have buzzy frequent updates compared to other frameworks.

But now, there are few information of Mezzo in Japanes (Laminas MVC, too), and this gives the feeling that the threshold is higher for the ordinary engineer (include me). If I had sufficient language skills, I could make some kind of contribution…