Is there any module or technique to implement anti-CSRF tokens into all requests in Drupal 9 for anonymous users?

1 Answer 1


Drupal already has CSRF protection for authenticated users.

One day core may add support to protect anonymous users as well.

In the meantime, you could look at the anonymous token module, or force all users to register/log in before using forms on the site.

  • Thanks for the answer. How can I add a CSRF token not only to forms but also to all custom requests? Could you please tell me any methods to do that? Oct 9, 2023 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.