简体   繁体   中英

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

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 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM