CSRF in Java+Spring+Thymeleaf
CSRF in Java+Spring+Thymeleaf
rytis
Posts: 4Questions: 1Answers: 1
Want to share my findings, which might look lik very simple and intuitive, but it took me couple days of research.
If anyone will want to use CSRF protection in Java+Spring+Thymeleaf environment and use POST method, the one should add the following code to DataTable section:
ajax: {
"url": "/modules/getSomething",
"type": "POST",
data: { "_csrf" :[[${_csrf.token}]] },
dataSrc: function ( json ) {
if(json.csrf_token !== undefined) $("meta[name=_csrf]").attr("content", json.csrf_token);
return json.data;
}
},
This discussion has been closed.
Replies
Hi,
Thanks for posting this! I'm sure others will find it useful.
Allan