Is it a good practice to store the csrf token in meta tag?

后端 未结 1 1795
一个人的身影
一个人的身影 2021-02-08 15:47

If I make a POST request without using form and want to prevent CSRF attack, what I can do is to set the csrf-token in meta tag and put it back to the header when the request is

1条回答
  •  遇见更好的自我
    2021-02-08 16:17

    Yes this is good practice. If you are using ajax I think this is the cleanest solution.

    You could also put the token inside of the form (which is more convenient if submitting the whole form), but if you are using ajax, it just needs to go somewhere that you can grab it.

    in a hidden field, or in a meta tag are both very good options.

    0 讨论(0)
提交回复
热议问题