Skip to content

Commit 6d7c87f

Browse files
Oviglojaviereguiluz
authored andcommittedMar 26, 2025
[Security] Add methods param doc for isCsrfTokenValid attribute
1 parent a0758ac commit 6d7c87f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎security/csrf.rst

+9
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ object evaluated to the id::
288288
// ... do something, like deleting an object
289289
}
290290

291+
You can use the ``methods`` parameter to the attribute to specify the HTTP methods that are allowed for
292+
the token validation, :class:`Symfony\\Component\\Security\\Http\\Attribute\\IsCsrfTokenValid` is ignored for other methods. By default, the attribute allows all methods::
293+
294+
#[IsCsrfTokenValid('delete-item', tokenKey: 'token', methods: ['DELETE'])]
295+
public function delete(Post $post): Response
296+
{
297+
// ... delete the object
298+
}
299+
291300
.. versionadded:: 7.1
292301

293302
The :class:`Symfony\\Component\\Security\\Http\\Attribute\\IsCsrfTokenValid`

0 commit comments

Comments
 (0)
Failed to load comments.