Question

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?

Was it helpful?

Solution

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'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top