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 2ecb02e

Browse filesBrowse files
committed
Merge branch '7.2' into 7.3
* 7.2: Minor tweaks [Security] iscsrftokenvalid-attribute-controller-usage
2 parents 91c2882 + 83b3092 commit 2ecb02e
Copy full SHA for 2ecb02e

File tree

1 file changed

+14
-0
lines changed
Filter options

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
@@ -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+
This attribute can also be applied to a controller class. When used this way,
285+
the CSRF token validation will be applied to **all actions** defined in that
286+
controller::
287+
288+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
289+
use Symfony\Component\Security\Http\Attribute\IsCsrfTokenValid;
290+
// ...
291+
292+
#[IsCsrfTokenValid('the token ID')]
293+
final class SomeController extends AbstractController
294+
{
295+
// ...
296+
}
297+
284298
The :class:`Symfony\\Component\\Security\\Http\\Attribute\\IsCsrfTokenValid`
285299
attribute also accepts an :class:`Symfony\\Component\\ExpressionLanguage\\Expression`
286300
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.