Hi,

a couple of weeks ago, I wrote a little test script to demonstrate the
Zend\Permissions\Rbac component. It worked as expected with the
2.1.0-dev version I used. After rechecking the script with 2.1.0 now,
the results have changed. Here is the script for copy / pasting:

========================================================================

use Zend\Debug\Debug;
use Zend\Permissions\Rbac\Rbac;
use Zend\Permissions\Rbac\Role;

$roleGuest = new Role('guest');
$roleGuest->addPermission('pizza_list');
$roleGuest->addPermission('pizza_show');

$roleCustomer = new Role('customer');
$roleCustomer->addPermission('pizza_basket');
$roleCustomer->addPermission('order_create');
$roleCustomer->addPermission('order_send');
$roleCustomer->setParent($roleGuest);

$roleStaff = new Role('staff');
$roleStaff->addPermission('pizza_create');
$roleStaff->addPermission('pizza_update');
$roleStaff->addPermission('order_update');
$roleStaff->addPermission('order_cancel');
$roleStaff->addPermission('order_finish');
$roleStaff->setParent($roleCustomer);

$roleAdmin = new Role('admin');
$roleAdmin->addPermission('pizza_delete');
$roleAdmin->addPermission('order_delete');
$roleAdmin->setParent($roleStaff);

$rbac = new Rbac();
$rbac->addRole($roleGuest);
$rbac->addRole($roleCustomer);
$rbac->addRole($roleStaff);
$rbac->addRole($roleAdmin);

Debug::dump($rbac->isGranted('guest', 'pizza_list'));
Debug::dump($rbac->isGranted('customer', 'pizza_basket'));
Debug::dump($rbac->isGranted('customer', 'pizza_list'));
Debug::dump($rbac->isGranted('staff', 'pizza_list'));
Debug::dump($rbac->isGranted('staff', 'order_cancel'));
Debug::dump($rbac->isGranted('admin', 'pizza_delete'));
Debug::dump($rbac->isGranted('admin', 'order_create'));

Debug::dump($rbac->isGranted('guest', 'pizza_create'));
Debug::dump($rbac->isGranted('customer', 'order_finish'));
Debug::dump($rbac->isGranted('staff', 'order_delete'));
Debug::dump($rbac->isGranted('admin', 'order_copy'));

========================================================================

With the 2.1.0-dev release the first seven Dumps showed true and the
last four showed false. Now only the first, second, fifth and sixth show
true, all other show false. My feelings are that the parent inheritance
is not working any more. So, the "customer" is not inheriting the
"pizza_list" right from the "guest".

Could any one explain, what happened?

Regards,

Ralf

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to