问题
I have been integrating the Auth and Acl with ZF2 in my application. I have followed the tutorial. http://p0l0.binware.org/index.php/2012/02/18/zend-framework-2-authentication-acl-using-eventmanager/
But, i can't get the features of ACL. I have the used the ACL in Auth module instead of Users. How can i restrict the access for guest? How to allow the member for all pages access?
I have not changed anything. Please check the tutorial.
Can anyone please sort out my problem? or else guide me to do. Thanks.
回答1:
Just starting to explore ACL. your problem comes up first in google search result. It is clear that the namespaces in use in the tutorial are wrong (use Zend\Acl\Acl as ZendAcl,).
The ACL namespace is:
namespace Zend\Permissions\Acl;
class Acl implements AclInterface
回答2:
ACL Setup in five minutes this is quick and easy way of setting up acl in your zendframework 2 application
回答3:
I've had the same problem to resolve auth+acl control issue and finnaly I've got it. It's simple:
1 - Create a global or a special module acl config file: ....module/Profil/config/acl.config.php
You can place it under the global config directory of the application
return array(
'acl' => array(
'roles' => array(
'guest' => null,
'member' => 'guest',
'admin' => 'member'
),
'resources' => array(
'Profil' => array(
'Index' => array(
'allow' => array(
// action => member
'signup' => 'guest',
'index' => 'guest', // signin ;)
'home' => 'member',
'signout' => 'member',
'all' => 'admin',
),
'deny' => array(
'home' => 'guest',
),
),
),
),
),
);
Here I've defined how my module "Profil" can work and the roles that can use it and the limits for each one of them.
Roles:
A guest has no parent.
A member inherits from the guest permissions.
The boss admin inherits from both member and guest.
来源:https://stackoverflow.com/questions/14155085/zend-framework-2-acl-implementation