Henrik Bjrnskov

Hello there! I am a developer with a big crush on open source. I work for Firmafon/Firma.co in Copenhagen, Denmark.

You can see of my open source projects on GitHub (Stampie, Bernard etc.) and read my ramblings on Twitter.

Symfony2: Quick tip for your security configuration

24 Dec 2011

Earlier when playing around with the Security component and SecurityBundle i found that for all paths you can specify a route name and the component will match it when check for the request paths. The following example shows how easy it is.

# app/config/security.yml
            pattern: ^/
                login_path: session_new
                check_path: session_new
                path: session_delete
                target: homepage

So now you do not have to change your security configuration everytime you change the url of your application.

It does not work, you liar!?

Infact it does, but check_path is validated with the pattern specified for your firewall. This happens so early in the request cycle that access to all routes are not available yet. So until that is fixed you should uncomment line 277 in SecurityBundle/DependencyInjection/MainConfiguration.php if you want it to work.