Skip to content

Commit 8ded86a

Browse files
committed
Use new security.authorization_checker service
Replace deprecated `security.context` with the `security.authorization_checker` service.
1 parent b1503b9 commit 8ded86a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

best_practices/security.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ Authorization (i.e. Denying Access)
7575
Symfony gives you several ways to enforce authorization, including the ``access_control``
7676
configuration in :doc:`security.yml </reference/configuration/security>` the
7777
:ref:`@Security annotation <best-practices-security-annotation>` and using
78-
:ref:`isGranted <best-practices-directly-isGranted>` on the ``security.context``
78+
:ref:`isGranted <best-practices-directly-isGranted>` on the ``security.authorization_checker``
7979
service directly.
8080

8181
.. best-practice::
8282

8383
* For protecting broad URL patterns, use ``access_control``;
8484
* Whenever possible, use the ``@Security`` annotation;
85-
* Check security directly on the ``security.context`` service whenever
85+
* Check security directly on the ``security.authorization_checker`` service whenever
8686
you have a more complex situation.
8787

8888
There are also different ways to centralize your authorization logic, like
@@ -315,7 +315,7 @@ Now, you can use the voter with the ``@Security`` annotation:
315315
// ...
316316
}
317317
318-
You can also use this directly with the ``security.context`` service, or
318+
You can also use this directly with the ``security.authorization_checker`` service, or
319319
via the even easier shortcut in a controller:
320320

321321
.. code-block:: php
@@ -327,7 +327,7 @@ via the even easier shortcut in a controller:
327327
{
328328
$post = // query for the post ...
329329
330-
if (!$this->get('security.context')->isGranted('edit', $post)) {
330+
if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
331331
throw $this->createAccessDeniedException();
332332
}
333333
}

0 commit comments

Comments
 (0)