[英]Symfony2 anonymous and authenticated on same route
I would have liked in Symfony2 "v2.1" a page that can be accessed without authentication and Authenticated. 我希望在Symfony2“ v2.1”中有一个无需身份验证和身份验证即可访问的页面。
I used the anonymous, but here is a token of the Authenticated User Anonymous and not be proper token. 我使用了匿名,但这是Authenticated User Anonymous的令牌,而不是适当的令牌。
Does anyone have a solution 有没有人有办法解决吗
As mentioned in the security : 如安全性中所述:
Anonymous users are technically authenticated, meaning that the isAuthenticated() method of an anonymous user object will return true. 匿名用户经过技术验证,这意味着匿名用户对象的isAuthenticated()方法将返回true。
//if you want myPage to be accessible by everyone
security:
firewalls:
secured_area:
pattern: ^/
anonymous: ~
access_control:
- { path: ^/myPage, roles: IS_AUTHENTICATED_ANONYMOUSLY }
If you remove the anonymous key, the firewall will always make a user fully authenticate immediately. 如果删除匿名密钥,防火墙将始终使用户立即完全认证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.