sylvainjule / kirby-bouncer

Restrict access of a user role to a specific page (and its children) in the panel.
MIT License
61 stars 6 forks source link

Added 'extra-allowed' array to config #30

Open Greakz opened 8 months ago

Greakz commented 8 months ago

I added an extra configuration option to the plugin. With that, the list of allowed-pages can be extended in the kirby configuration to allow the creation of areas in other plugins.

An example config now looks like:

'sylvainjule.bouncer' => [
        'list'=> [
            '<role>' => [
                'fieldname' => 'canaccess'
            ],
        ],
        'extra-allowed' => [
            [
                'title' => 'Area Title',
                'path'  => '/area-path'
            ]
        ]
    ]
animaux commented 7 months ago

Nice, exactly what I needed just now. Is there a way to include all subpages of a path as well?

Greakz commented 7 months ago

Nice, exactly what I needed just now. Is there a way to include all subpages of a path as well?

I think there is currently no way for allowing all subpages of a given path as well. As you can see in lib/bouncer.php (Around Line 19) all child pages are added to the list of allowed pages and in index.php (Line 38) the check will look for an exact match in the array of allowed paths. In order to allow subpages, this check have to be changed.

animaux commented 7 months ago

@Greakz thanks for pointing out the logic behind this. I guess it should be fine if it’s not too much subpages.