Zend 1 wrapper in Symfony 2. How to share a session?

In my work, we are working on porting our Zend 1 application to Symfony 2. I tried to figure out how to do this harmlessly. I found the following SF2 Bundle: https://github.com/mainlycode/Zf1WrapperBundle . I installed it, followed the setup instructions, copied the Zend application to / vendor / zend, and everything works very well. When I look at my old login, SF2 cannot understand it and ask for an answer to Zend, and my login form will appear. I can log in and it works, part of the site authentication is displayed correctly.

Now I want to start updating the function where the user should be completed. So I created a new SF2 package called BackendBundle. He tried this in my controller:

$securityContext = $this->container->get('security.context');
if( $securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') ){
    echo 'AUTHED';
}

But I get the following error:

The security context contains no authentication token. One possible reason may be that there is no firewall configured for this URL. 

I fully understand why. But I really don't know how I can “share” authentication between Zend and SF2. Any suggestions?

+4
source share
1 answer

My first assumption was to share a session (configure both ZF and Sf2 to use a similar SessionHandler), but Sf2 stores session information in a very specific way that ZF probably won't easily support.

But I think you could try creating an Sf2 RequestListener that will read your ZF session, find the authentication token in it, and then create the Sf2 authentication token to finally insert it into the SecurityContext.

?

0

Source: https://habr.com/ru/post/1547774/


All Articles