Archives


Master Symfony2 fundamentals

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).
trainings.sensiolabs.com

Discover the SensioLabs Support

Access to the SensioLabs Competency Center for an exclusive and tailor-made support on Symfony
sensiolabs.com

Fabien Potencier
New in Symfony 2.4: Restrict Security Firewalls to specific Hosts
by Fabien Potencier – September 08, 2013 – 3 comments

Contributed by
Peter Kruithof
in #8905.

Symfony 2.2 introduced host support in the routing system. Symfony 2.4 does the same for the security firewall configuration.

When configuring a firewall, you can restrict it to a given URL path pattern, like ^/admin/:

1
2
3
admin:
    pattern:    ^/admin
    http_basic: true

But what if you want to restrict it to admin.example.com instead? As of Symfony 2.4, this is really easy:

1
2
3
4
host:
    pattern:    ^/
    host:       admin\.example\.com
    http_basic: true

Simple and powerful!

Comments RSS

  • Patrik Karisch
    #1 Patrik Karisch said on the 2013/09/08 at 16:12
    +1 very nice feature. Especcialy for an api.example.com url a missed feature.
  • Seweryn Zeman
    #2 Seweryn Zeman said on the 2013/09/08 at 21:27
    Finally! Good job! : )
  • Jacek Jędrzejewski
    #3 Jacek Jędrzejewski said on the 2013/09/10 at 21:55
    Argh, I was too late, also wanted to make this PR! :)