且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Symfony2-设置安全性access_control以仅允许匿名认证

更新时间:2023-11-19 16:03:52

您可以使用 has_role()测试 IS _ * 吗?这些角色就像角色,但不是角色。也许这就是为什么它总是返回 false 的原因:

Are you sure you can test IS_* using has_role()? These act like roles but they're not roles. Maybe that's why it always returns false:

  • http://symfony.com/doc/current/security.html#checking-to-see-if-a-user-is-logged-in-is-authenticated-fully

似乎您***使用 is_anonymous() is_authenticated() allow_if 表达式中的自定义函数。

It seems like you should better use is_anonymous() and is_authenticated() custom functions in the allow_if expression.

  • http://symfony.com/doc/current/expressions.html#security-expression-variables