When using spring security, we can use CSRF token. We may use in spring security xml, and in jsp
> (<sec:csrfInput /> or <input type=”hidden”
> name=”${_csrf.parameterName}” value=”${_csrf.token}”/>).
But how do I get the csrf token name and value in Java area?
I have to send a mail to users from service layer in my web app. And csrf token must exist inside of mail contents.
String html = new String( "<div style='width:600px; height:300px; margin:0 auto;'>" +
"<h2 style='color:#FFBB00;'>lock release system</h2>" +
"<p style='color:#2F9D27'>your account has been locked. If you want to release the lock, you should click 'release user lock' button below." +
"</p>" +
"<hr>" +
"<form action='http://122.40.73.117:9000/whiteboard/user/release-lock-user' method='post' target='_blank'>" +
"<input type='hidden' name='email' value='" + email + "' />" +
"<input type='hidden' name='csrf' value='" + csrf + "' />" +
"<button type='submit' style='font-weight:bold;'>release user lock</button>" +
"</form>" +
"</div>");
The code above uses CSRF variable, but that is just a dummy variable. How do I set CSRF ?