In my job, we are working on migrating our Zend 1 app to Symfony 2. I tried to figure how to do this harmlessly. I found the following SF2 Bundle : https://github.com/mainlycode/Zf1WrapperBundle. I installed it, followed the configuration instructions, copied my Zend app in /vendor/zend and everything is working pretty fine. When I browse my old login route, SF2 can't understand it and ask the response to Zend, and my login form appears. I can log in, and it works, the authed part of the site displays correctly.
Now I want to start revamp a feature where the user needs to be authed. So I created a new SF2 bundle, called BackendBundle. It 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 totally understand why. But I really dont know how I can "share" the authentification between Zend and SF2.
Any suggestions ?
My first guess was to share the session (configure both ZF and Sf2 to use a similar SessionHandler), but Sf2 stores session information in a very specific way that ZF would probably not support easily.
But I guess you could try to create an Sf2 RequestListener which would read your ZF session, find an auth token in it, then create an Sf2 auth token to finally inject it to the SecurityContext.
What d'you think about that?
Related
I'm trying to integrate a legacy application in symfony fullstack.
Because of poor infrastructure I have to stick to symfony 2.8.
Everything works so far, but i think i maybe have a problem with sessions.
(I read the symfony articles about integrating legacy sessions and tried everything)
The Toolbar says "You are not authenticated".
Normally there is "Authenticated anonymously".
This is how it should look.
(Screen from a plain install of symfony2.8 in the exact same version i use)
What are possible reasons for that?
Thanks for your help.
Somehow the legacy application failed and directly rendered a response from within an event listener. I can't really explain it, but now it works.
I am using Symfony framework in my project and now I am trying to add Steam Authentication to my project, so I could use Steam account informations in my project. Earlier is used only plain PHP, no frameworks and I found this https://github.com/SmItH197/SteamAuthentication and it worked well, but I am not sure that can I use it with Symfony? I mean, how to include it in my controller? Or is there another way to Steam Authenticate with Symfony?
You should write a custom authenticator for this. This way, you can easily adapt it into the current Symfony security system. Take a look at the documentation for this at: http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html
Indeed you could, as many others already have, one such example for Symfony2 is here: https://github.com/SirWaddles/SteamAuthBundle :) good luck.
I have a project built in Symfony2. I'm using FOSUserBundle to manage users. Now I have to integrate Wordpress into my project. Wordpress has to be available in subfolder: http://example.com/blog. I already managed to achieve such state, everything works like a charm, but now I need to share session between Symfony2 project and Wordpress. Actually I don't really know if session share is right solution to my problem. The thing is that I want to the same design in Wordpress as I use in Symfony project. In my Symfony project I have a top bar which indicates that user is authenticated. If user will authenticate via Symfony (I want it to be the only possible way) I want him to see that he is authenticated also while browsing the Wordpress blog. So session share was my first thought, but maybe there are other, more effective solutions? Maybe loading this top bar into iframe in Wordpress? Can EkinoWordpressBundle solve my problem?
If the WordPress installation is on the same domain in a folder, the session should be available trough PHP. You can check it by using the $_SESSION variable from PHP and add some code to your header.php to show the authentication details .
I'm migrating a symfony1.4 application to symfony 2.5, and we need to run both applications simultaneously seamlessly to the end user.
The idea is to land on sf2 app and if a certain route does not exist, then route (fall back) to the sf1 app.
The challenge here is to use the same domain.
For instance:
www.mydomain.com/ > lands on sf2 home page.
www.mydomain.com/contact-us > routes to an existing sf2 controller/view
www.mydomain.com/some-form > does not exists in sf2 app, then it redirects/forwards to the legacy sf1.4 app keeping the same url (user doesn't need to notice the forwarding)
Any ideas on how to best approach this?
Cheers,
Fabian
I think this wrapper bundle was designed for your purpose:
https://github.com/theodo/TheodoEvolutionLegacyWrapperBundle
This bundle allows you to call the legacy framework from Symfony2. Tested and works for legacy app made with symfony 1.4.
I am learning Laravel. With composer i included the mobile-detect-bundle in the installation (files are in the folders). When i use the code as stated in the docs on github
$mobileDetector = $this->get('mobile_detect.mobile_detector');
i get this error:
**ErrorException**
File does not exist at path mobile_detect.mobile_detector (View: ) (View: )
I use this in my blade view and i think i have to set the path of 'mobile_detect.mobile_detector' but i have no clue what it has to be. Maybe one can give me a push in the right direction?
The reason it's not working is because you are trying to use a Symfony 2 bundle inside Laravel right out of the box.
As the github page says:
Symfony2 bundle for detect mobile devices, manage mobile view and redirect to the mobile and tablet version.
Basically, the line that you are trying to run is the way that you use services inside Symfony. It will work if you are in a Symfony application, but not inside Laravel.
// Get the mobile_detect.mobile_detector
// service from Symfony's service container
$mobileDetector = $this->get('mobile_detect.mobile_detector');
Although there might be some way to make it work, I'd sugggest to search in packagist for a Laravel specific package, or a PHP generic one that provides the same functionality, to make your life easier.
I've made a search and found this one, which is based in Mobile Detect too:
https://github.com/jenssegers/Laravel-Agent