AKKAweb
AKKAweb

Reputation: 3807

CakePHP - CakeDC Plugin Permission Not Working

I have been using the following plugin (https://github.com/CakeDC/users) for CakePHP, but I can't figure out how to get the permissions working for it. I have followed all instructions, but it seems authorize does not get used at all. Wondering if anyone has any tips on how to make it work. Here is my setup:

bootstrap.php

Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);

AppController.php initialize function

$this->loadComponent('CakeDC/Users.UsersAuth');

config/users.php

$config = [
    'Auth' => [
        'authError' => 'Did you really think you are allowed to see that?'
    ]
];

return $config;

config/permissions.php

return [
    'Users.SimpleRbac.permissions' => [
        [
            'role' => '*',
            'controller' => 'Pages',
            'action' => ['display'],
            'allowed' => true
        ], [
            'role' => '*',
            'controller' => 'Taxes',
            'action' => ['*'],
            'allowed' => true
        ], [
            'role' => '*',
            'prefix' => 'v1',
            'controller' => '*',
            'action' => '*',
            'allowed' => true
        ]
    ]
];

return $config;

Frankly it seems a CakePHP configuration issue, but I am not able to find where that problem is coming from. I say that because even though debug shows the correct file loaded to authorize, it does not get called.

Upvotes: 2

Views: 662

Answers (1)

steinkel
steinkel

Reputation: 1186

Please ensure you are returning the $config variable in the users.php file and you are initializing the plugin correctly as indicated here https://github.com/CakeDC/users/blob/master/Docs/Documentation/Configuration.md

Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);

I've created a test environment here with your provided Auth configuration and it works correctly https://ide.c9.io/steinkel/users-so-42523209

https://nimbus.everhelper.me/client/notes/share/790695/girguwv9x7rttdvu5c4x

Thanks,

Upvotes: 2

Related Questions