ZF-Commons / ZfcAcl

A generic and flexible ACL implementation for ZF2.
BSD 3-Clause "New" or "Revised" License
65 stars 15 forks source link

guest is not allowed to access dispatchable index (dispatchable/index) #11

Open ghost opened 12 years ago

ghost commented 12 years ago

Hi there, I got this error. I don't understand why.

matuszeman commented 12 years ago

Hey, It's because Dispatch guard is enabled and "guest" user (you are not logged in) has got no privileges on "dispatchable/index" resource (index controller).

What user/authentication module do you use? Is it KapitchiIdentity or ZfcUser? In order to use ZfcAcl you need to implement RoleProvider and inject it to Acl service.

Matus

ghost commented 12 years ago

Hi, i'm using ZfcUser (with ZfcUserDoctrineORM). Here is what i did: 1 - i make a copy of ZfcAcl.global.config.php into my config/autoload directory 2- i make a copy of KapitchiIdentity/src/KapitchiIdentityAcl/Service/RoleProvider.php into Application/src/Application/Plugin/ZfcAcl/RoleProvider.php 3 - i configured ZfcAcl.global.config.php with : 'roleProvider' => 'Application\Plugin\ZfcAcl\RoleProvider',

But now i suppose i should call somewhere RoleProvider::setIdentityRoleService($identityRoleService) using $aclService but i don't know how.

My current error is following because $this->getIdentityRoleService() is null: Fatal error: Call to a member function getCurrentRole() on a non-object in N:\DEV\APPLICATIONS\zf2\module\Application\src\Application\Plugin\ZfcAcl\RoleProvider.php on line 11

https://github.com/kapitchi/KapitchiIdentity/blob/master/src/KapitchiIdentityAcl/Service/RoleProvider.php#L11

matuszeman commented 12 years ago

ZfcUser does not provide roles. Although you might want to implement role provider this way: