Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76c0473

Browse filesBrowse files
committed
[Security] iscsrftokenvalid-attribute-controller-usage
1 parent b36bab2 commit 76c0473
Copy full SHA for 76c0473

File tree

Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed

‎security/csrf.rst

Copy file name to clipboardExpand all lines: security/csrf.rst
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
276290
The :class:`Symfony\\Component\\Security\\Http\\Attribute\\IsCsrfTokenValid`
277291
attribute also accepts an :class:`Symfony\\Component\\ExpressionLanguage\\Expression`
278292
object evaluated to the id::

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.