Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0b07226

Browse filesBrowse files
natewiebe13Nate Wiebe
authored and
Nate Wiebe
committed
Add tip for using new isGrantedForUser() function
1 parent 6c341c3 commit 0b07226
Copy full SHA for 0b07226

File tree

1 file changed

+12
-0
lines changed
Filter options

1 file changed

+12
-0
lines changed

‎security.rst

Copy file name to clipboardExpand all lines: security.rst
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,18 @@ want to include extra details only for users that have a ``ROLE_SALES_ADMIN`` ro
25852585
// ...
25862586
}
25872587
2588+
.. tip::
2589+
2590+
Using ``isGranted()`` checks authorization against the currently logged in user. If you need to check
2591+
against a user that is not the one logged in or if checking authorization when the user session is not
2592+
available in a CLI context (example: message queue, cronjob) ``isGrantedForUser()`` can be used to set the
2593+
target user explicitly.
2594+
2595+
.. versionadded:: 7.3
2596+
2597+
The :method:`Symfony\\Bundle\\SecurityBundle\\Security::isGrantedForUser`
2598+
method was introduced in Symfony 6.4.
2599+
25882600
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
25892601
Symfony will automatically pass the ``security.helper`` to your service
25902602
thanks to autowiring and the ``Security`` type-hint.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.