File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -273,6 +273,20 @@ Suppose you want a CSRF token per item, so in the template you have something li
273273 <button type="submit">Delete item</button>
274274 </form>
275275
276+ In addition :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsCsrfTokenValid `
277+ attribute can be applied to a controller class.
278+ This will cause the CSRF token validation to be executed for all routes defined within the controller::
279+
280+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
281+ use Symfony\Component\Security\Http\Attribute\IsCsrfTokenValid;
282+ // ...
283+
284+ #[IsCsrfTokenValid('controller')]
285+ final class FooController extends AbstractController
286+ {
287+ // ...
288+ }
289+
276290The :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsCsrfTokenValid `
277291attribute also accepts an :class: `Symfony\\ Component\\ ExpressionLanguage\\ Expression `
278292object evaluated to the id::
You can’t perform that action at this time.
0 commit comments