[英]Secure area in Symfony2
I have a question to the security features of Symfony2. 我对Symfony2的安全功能有疑问。 I want to protect a special area of my application under the
/my
prefix. 我想在
/my
前缀下保护应用程序的特殊区域。
My configuration looks like follows: 我的配置如下所示:
security.config:
providers:
my:
entity: { class: MyUserBundle:User, property: username }
firewalls:
public:
pattern: /my/login.*
security: false
my:
pattern: /my.*
form-login:
check_path: /my/login_check
login_path: /my/login
logout: true
access_control:
- { path: /my/login.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
When I try to access the login area, everything works fine, submitting the form leads to an error page, because there is no registered controller for the _security_check
route, like its described in the guide : 当我尝试访问登录区域时,一切正常,提交表单会导致错误页面,因为
_security_check
路由没有注册的控制器,如指南中所述:
_security_login:
pattern: /my/login
defaults: { _controller: MyUserBundle:Auth:login }
_security_check:
pattern: /my/login_check
I think normally the SecurityBundle hacks into this process so that no controller is needed. 我认为通常SecurityBundle会侵入此过程,因此不需要控制器。 The configuration of Symfony2 is allways very complex.
Symfony2的配置始终非常复杂。
I think I missed something, hope you can help. 我想我错过了一些事情,希望能对您有所帮助。
Thanks in advance! 提前致谢!
我在symfony用户邮件组的帮助下解决了这个问题。
您必须定义一个防火墙(描述所有路由),并使用设置的access_control部分确定安全区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.