File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2543,6 +2543,29 @@ You can also extend the ``IsGranted`` attribute to create meaningful shortcuts::
2543
2543
The :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsGranted `
2544
2544
attribute is extendable since Symfony 7.4.
2545
2545
2546
+ You can restrict access validation to specific HTTP methods
2547
+ by using the ``methods `` argument::
2548
+
2549
+ // src/Controller/AdminController.php
2550
+ // ...
2551
+
2552
+ use Symfony\Component\Security\Http\Attribute\IsGranted;
2553
+
2554
+ #[IsGranted('ROLE_ADMIN', methods: 'POST')]
2555
+ class AdminController extends AbstractController
2556
+ {
2557
+ // You can also specify an array of methods
2558
+ #[IsGranted('ROLE_SUPER_ADMIN', methods: ['GET', 'PUT'])]
2559
+ public function adminDashboard(): Response
2560
+ {
2561
+ // ...
2562
+ }
2563
+ }
2564
+
2565
+ .. versionadded :: 7.4
2566
+
2567
+ The ``methods `` argument was introduced in Symfony 7.4.
2568
+
2546
2569
.. _security-template :
2547
2570
2548
2571
Access Control in Templates
You can’t perform that action at this time.
0 commit comments