ZfcRbac and identity getting issue

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

ZfcRbac and identity getting issue

Mohammad ZeinEddin
can any one please help answering this question?

I have a ZF2 application that uses ZfcRbac, and it is integrated with an
old existing application, and so I need to get the authentication from the
other application, and I do get the identity from the old system by a
function as the following:

$em->attach(\Zend\Mvc\MvcEvent::EVENT_ROUTE, array($this,
'checkAuthentication'), 100);

and in ZfcRbac configuration I changed the identity provider and I get and
identity for ZfcRbac as the following:

'service_manager' => array(
    'factories' => array(
        'standard_identity' => function ($sm) {
            $someIdentity = $sm->get('SomeAuthService')->getIdentity();
            $roles = $someIdentity->getRoles();
            $identity = new \ZfcRbac\Identity\StandardIdentity($roles);
            return $identity;

but the problem is that the first time I request the page I can not get the
identity from the authentication service since the 'standard_identity' will
execute the code in the "onBootStrap" and it will find the session storage
empty and so I will always get 'unauthorized' access. I want the standard
identity to execute somehow after the event route because then I will have
the identity saved. any one can help with that?
Best Regards,