0

I'm having an issue with zfcrbac that I can't figure out.

I think I might missed something in configuration but I have read a few times the documentation with out any clue.

Whenever I try to use this I get

"Argument 1 passed to ZfcRbac\Service\RoleService::__construct() must be an instance of ZfcRbac\Identity\IdentityProviderInterface, instance of Zend\Authentication\AuthenticationService given"

I have

'identity_provider' => 'AuthService',

To which AuthService is the alias for Zend\Authentication\AuthenticationService

and I have it configured like this

'factories' => array(
            'Auth\Model\AuthStorage' => function($sm){
                return new \Auth\Model\AuthStorage('auth_user');  
            },

            'AuthService' => function($sm) {
                $dbAdapter      = $sm->get('Zend\Db\Adapter\Adapter');
                $dbTableAuthAdapter  = new DbTableAuthAdapter($dbAdapter, 'user','username','password', 'md5(concat("' . $staticSalt . '" ,?,passwordSalt)) and active=1');

                $authService = new AuthenticationService();
                $authService->setAdapter($dbTableAuthAdapter);
                $authService->setStorage($sm->get('Auth\Model\AuthStorage'));


                return $authService;
            },
        ),

So I don't know what am I missing?

user973783
  • 111
  • 7

1 Answers1

3

As said in the doc: https://github.com/ZF-Commons/zfc-rbac/blob/master/config/zfc_rbac.global.php.dist#L28

The service name for the identity_provider option must return an instance that implements ZfcRbac\Identity\IdentityProviderInterface. We provide a built-in one that uses AuthenticationService: https://github.com/ZF-Commons/zfc-rbac/blob/master/config/zfc_rbac.global.php.dist#L31

I recommend you staying with the default. To construct ZfcRbac\Identity\AuthenticationIdentityProvider, ZfcRbac fetches Zend\Authentication\AuthenticationService from its factory. So what you need actually is replacing AuthService in your config by 'Zend\Authentication\AuthenticationService'.

Michael Gallego
  • 1,746
  • 1
  • 20
  • 29
  • Ok, I changed 'identity_provider' => 'AuthService' for 'identity_provider' => 'ZfcRbac\Identity\AuthenticationIdentityProvider' And chenged this 'AuthService' => function($sm) { for 'Zend\Authentication\AuthenticationService' => function($sm) { I'm not getting errors now, but If I enable guards, it is not respecting the roles, is there a way to print out the role and permissions so I can know what permissions this user have? – user973783 Mar 24 '14 at 22:31
  • 1
    What do you mean by not respecting the roles? Did you properly configure the role provider ? Regarding printing role and permissions, you should install ZendDeveloperTools, it provides built-in debug tools for ZfcRbac :). – Michael Gallego Mar 25 '14 at 17:18
  • Oh great!, I initially disabled ZendDeveloperTools because I was having some issues with it, but now it's working correctly, thank you so much – user973783 Mar 26 '14 at 00:01