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 @@ -281,6 +281,20 @@ Suppose you want a CSRF token per item, so in the template you have something li
281281 <button type="submit">Delete item</button>
282282 </form>
283283
284+ In addition :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsCsrfTokenValid `
285+ attribute can be applied to a controller class.
286+ This will cause the CSRF token validation to be executed for all routes defined within the controller::
287+
288+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
289+ use Symfony\Component\Security\Http\Attribute\IsCsrfTokenValid;
290+ // ...
291+
292+ #[IsCsrfTokenValid('controller')]
293+ final class FooController extends AbstractController
294+ {
295+ // ...
296+ }
297+
284298The :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsCsrfTokenValid `
285299attribute also accepts an :class: `Symfony\\ Component\\ ExpressionLanguage\\ Expression `
286300object evaluated to the id::
You can’t perform that action at this time.
0 commit comments