Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,20 @@ Just like when creating a controller for a route, the order of the arguments of
order of the arguments, Symfony will still pass the correct value to each
variable.

Checking the Validity of a CSRF Token
-------------------------------------

Sometimes you want to use CSRF protection in an action where you don't want to use a
Symfony form.

If, for example, you're doing a DELETE action, you can use the
:method:`Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\CsrfProviderAdapter::isTokenValid`
method to check the CSRF token::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that this sentence should be worded more "smoothy". Though I'm not sure how. Maybe our native speaker @weaverryan has a suggestion.


use Symfony\Component\Security\Csrf\CsrfToken;

$this->get('security.csrf.token_manager')->isTokenValid(new CsrfToken('token_id', 'TOKEN'));

Final Thoughts
--------------

Expand Down