Symfony2 每主机访问控制 [英] Symfony2 per-host access control
问题描述
我正在尝试在 Symfony 2.2 中实现主机路由.我已将路由添加到 app/config/routing.yml,但 app/config/security.yml 中的安全限制正在重定向请求.
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.
例如,我有 (www.)domain1.com 和 {subdomain}.domain2.com.我希望 security.yml 中的安全限制仅适用于 {subdomain}.domain2.com(我的应用),而不适用于 (www.)domain1.com(我的主页).
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
推荐答案
您可以使用 ACL 通过主机名限制访问,如下所示:
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 }
这篇关于Symfony2 每主机访问控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!