From a3d8b844f0549c88f6b16190af4e6023a3cc9a11 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Thu, 18 Feb 2021 13:53:38 -0500 Subject: [PATCH] Added csrf thymeleaf examples --- csrf.html | 4 ++++ csrf.js | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 csrf.html create mode 100644 csrf.js diff --git a/csrf.html b/csrf.html new file mode 100644 index 0000000..32f0d72 --- /dev/null +++ b/csrf.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/csrf.js b/csrf.js new file mode 100644 index 0000000..e593a1a --- /dev/null +++ b/csrf.js @@ -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); + }); +} \ No newline at end of file