As I am moving from Spring 3.1.1.RELEASE to 4.0.2 RELEASE I have had to make some changes to spring security context.
Almost everything is ok except POST Request for logout.
I could make entire line to be form method="POST" action="logout" but then I have to deal with Submit which is totally different styling then what we need. I have tried sending logout request with csrf data over ajax with no success. Any help is greatly appreciated. P.S. Disabling csrf is not an option.
<!-- JSP -->
<meta name="_csrf" content="${_csrf.token}"/>
<!-- default header name is X-CSRF-TOKEN -->
<meta name="_csrf_header" content="${_csrf.headerName}"/>
<!--Anchor -->
<a id="loggg" href="logout">Logout1</a>
<!-- jquery -->
$("#loggg").click(function(e){
e.preventDefault();
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
$.ajax({
url : "logout",
method : "POST",
data :token ,
success : function(data) {
console.log("clicked");
},
error : function(data) {
console.log(data);
}
});
})
FireBug developer console returns :
403 Forbidden 2ms
"NetworkError: 403 Forbidden - http://localhost:8081/nekretnine/logout"
Object { readyState=4, responseText="<!DOCTYPE html><html>
<he...EASE</h3></body></html>", status=403, more...}