ivanamat / cakephp3-aclmanager

CakePHP 3.x - Acl Manager
MIT License
27 stars 27 forks source link

Using this plugin with JWT? #10

Closed azanoni closed 7 years ago

azanoni commented 7 years ago

Hi!,

I want to know its it this possible using this with acl manager with https://github.com/ADmad/cakephp-jwt-auth. I need that the "acl manage the autorization": 'authorize' => [ 'Acl.Actions' => ['actionPath' => 'controllers/Api/'] ],

This is mu Api/AppController:

`<?php namespace App\Controller\Api;

use Cake\Controller\Controller; use Cake\Event\Event;

class AppController extends Controller {

use \Crud\Controller\ControllerTrait;

public $components = [
    'Acl' => [
        'className' => 'Acl.Acl'
    ]
];    

public function initialize()
{
    parent::initialize();

    $this->loadComponent('RequestHandler');
    $this->loadComponent('Crud.Crud', [
        'actions' => [
            'Crud.Index',
            'Crud.View',
            'Crud.Add',
            'Crud.Edit',
            'Crud.Delete'
        ],
        'listeners' => [
            'Crud.Api',
            'Crud.ApiPagination',
            'Crud.ApiQueryLog'
        ]
    ]);
    $this->loadComponent('Auth', [
        'authorize' => [
            'Acl.Actions' => ['actionPath' => 'controllers/Api/']
        ],            
        'storage' => 'Memory',
        'authenticate' => [
            'Form' => [
                'scope' => ['Users.active' => 1]
            ],
            'ADmad/JwtAuth.Jwt' => [
                'parameter' => 'token',
                'userModel' => 'Users',
                'scope' => ['Users.active' => 1],
                'fields' => [
                    'username' => 'id'
                ],
                'queryDatasource' => true
            ]
        ],
        'unauthorizedRedirect' => false,
        'checkAuthIn' => 'Controller.initialize'
    ]);
}

} ` But this is the message that I receive when acceses using RESTClient in http://localhost/dev/cakeacl/api/Posts.json

DbAcl::check() - Failed ACO node lookup in permissions check, the ACO are update, the permission in acl too...if I commented the line of "acl" works..but I need acl :(

ivanamat commented 7 years ago

Hi @azanoni,

Try updating to the latest version of the AclManager plugin and click on "Update ACOs and AROs and set default values" inside the panel of the AclManager plugin.

AclManager is a plugin that manages the ACL plugin, is not the one that establishes or checks the permissions, you should look for how to configure JWT and ACL plugin.

Anyway, try to do what I said, in the previous version there was a bug when updating the ACOs.

Read again README.md please, there are important changes.