mirror of
https://bitbucket.org/Mattrixwv/webtutorials.git
synced 2025-12-06 18:34:01 -05:00
Added csrf thymeleaf examples
This commit is contained in:
4
csrf.html
Normal file
4
csrf.html
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<!--This is an example of manual csrf token inclusion using thymeleaf-->
|
||||||
|
<meta name="_csrf" th:content="${_csrf.token}">
|
||||||
|
<meta name="_csrf_header" th:content="${_csrf.headerName}">
|
||||||
|
<meta name="_csrf_name" th:content="${_csrf.parameterName}">
|
||||||
11
csrf.js
Normal file
11
csrf.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
//This is an example of manual csrf token inclusion using thymeleaf
|
||||||
|
//This retrieves and sets up all of the data for the table
|
||||||
|
function setAjaxCsrfToken(){
|
||||||
|
console.log("setAjaxCsrfToken()");
|
||||||
|
var token = $("meta[name='_csrf']").attr("content");
|
||||||
|
var header = $("meta[name='_csrf_header']").attr("content");
|
||||||
|
|
||||||
|
$(document).ajaxSend(function(e, xhr, options){
|
||||||
|
xhr.setRequestHeader(header, token);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user