Skip to content

Commit 7eb3f83

Browse files
committedJan 4, 2025·
minor #6683 [Doc] Minor update in the security chapter (javiereguiluz)
This PR was merged into the 4.x branch. Discussion ---------- [Doc] Minor update in the security chapter If you only apply the attribute to the dashboard and not the CRUD controllers, they will be accessible to everyone. In any case, using `access_control` is a way easier solution to make your entire backend safe. Commits ------- 9d7e306 [Doc] Minor update in the security chapter
2 parents f38f1f7 + 9d7e306 commit 7eb3f83

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎doc/security.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Restrict Access to the Entire Backend
2323

2424
Using the `access_control option`_, you can tell Symfony to require certain
2525
permissions to browse the URL associated to the backend. This is simple to do
26-
because :ref:`each dashboard only uses a single URL <dashboard-route>`:
26+
because :ref:`dashboard routes share a common prefix <dashboard-route>`:
2727

2828
.. code-block:: yaml
2929
@@ -32,11 +32,13 @@ because :ref:`each dashboard only uses a single URL <dashboard-route>`:
3232
# ...
3333
3434
access_control:
35-
# change '/admin' by the URL used by your Dashboard
35+
# change '/admin' by the prefix used by your Dashboard URLs
3636
- { path: ^/admin, roles: ROLE_ADMIN }
3737
# ...
3838
39-
Another option is to use the `#[IsGranted] attribute`_ in the dashboard controller::
39+
Alternatively you can use the `#[IsGranted] attribute`_. However, this can be
40+
cumbersome because you must apply it to all dashboard controllers and to all the
41+
:doc:`CRUD controllers </crud>`::
4042

4143
// app/Controller/Admin/DashboardController.php
4244
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
@@ -49,6 +51,8 @@ Another option is to use the `#[IsGranted] attribute`_ in the dashboard controll
4951
// ...
5052
}
5153

54+
// don't forget to also apply #[IsGranted('ROLE_ADMIN')] to all CRUD controllers
55+
5256
.. _security-controllers:
5357

5458
Restrict Access to Some CRUD Controllers

0 commit comments

Comments
 (0)
Please sign in to comment.