Symfony2 per-host access control

2019-05-14 21:28发布

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

1条回答
Root(大扎)
2楼-- · 2019-05-14 22:09

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 }
查看更多
登录 后发表回答