Skip to content

[Security] Use the is_granted expression to keep consistency with php example above #4282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ Thanks to the SensioFrameworkExtraBundle, you can also secure your controller us
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

/**
* @Security("has_role('ROLE_ADMIN')")
* @Security("is_granted('ROLE_ADMIN')")
*/
public function helloAction($name)
{
Expand Down Expand Up @@ -1786,6 +1786,8 @@ Additionally, you have access to a number of functions inside the expression:
see below;
* ``has_role``: Checks to see if the user has the given role - equivalent
to an expression like ``'ROLE_ADMIN' in roles``.
* ``is_granted``: Similar to the php code like `$securityContext->isGranted('ROLE_USER')`.
Unlike `has_role` expression, `is_granted` will call your custom voters if defined.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add something like "(this can ony be used in the @Security annotation)" at the end of this item, to warn users and avoid confusion.


.. sidebar:: ``is_remember_me`` is different than checking ``IS_AUTHENTICATED_REMEMBERED``

Expand Down