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 @@ -2523,6 +2523,29 @@ that is thrown with the ``exceptionCode`` argument::
2523
2523
// ...
2524
2524
}
2525
2525
2526
+ You can restrict access validation to specific HTTP methods
2527
+ by using the ``methods `` argument::
2528
+
2529
+ // src/Controller/AdminController.php
2530
+ // ...
2531
+
2532
+ use Symfony\Component\Security\Http\Attribute\IsGranted;
2533
+
2534
+ #[IsGranted('ROLE_ADMIN', methods: 'POST')]
2535
+ class AdminController extends AbstractController
2536
+ {
2537
+ // You can also specify an array of methods
2538
+ #[IsGranted('ROLE_SUPER_ADMIN', methods: ['GET', 'PUT'])]
2539
+ public function adminDashboard(): Response
2540
+ {
2541
+ // ...
2542
+ }
2543
+ }
2544
+
2545
+ .. versionadded :: 7.4
2546
+
2547
+ The ``methods `` argument was introduced in Symfony 7.4.
2548
+
2526
2549
.. _security-template :
2527
2550
2528
2551
Access Control in Templates
You can’t perform that action at this time.
0 commit comments