Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 per-host access control

I am trying to implement host routing in Symfony 2.2. I have added the route to app/config/routing.yml, but the security restrictions in app/config/security.yml are redirecting the requests.

For example, I have (www.)domain1.com and {subdomain}.domain2.com. I want the security restrictions in security.yml to apply only to {subdomain}.domain2.com (my app), and not to (www.)domain1.com (my home page).

How can this be achieved? I am looking for something like this:

security:
    firewalls:
        home_page:
            host:  (www.)domain1.com
            security: false
like image 474
James Avatar asked Mar 23 '23 15:03

James


1 Answers

You can restrict access by hostname with ACL like this:

# app/config/security.yml
security:
    # ...
    access_control:
        - { roles: ROLE_USER_WWW, host: www.yourdomain.com }
        - { roles: ROLE_USER, host: yourdomain.com }
like image 96
Nicolai Fröhlich Avatar answered Apr 19 '23 08:04

Nicolai Fröhlich