I couldn't solve this issue.
I try to athentication login logout example here. Login is work properly but when I try to logout, browser gives NetworkError : 403 forbidden localhost:8080/logout is forbidden.
In my opinion I should add token header every request from ui side.But I don't know and find how can I do that?
here is the browser developer tools message :
POST 403 {"timestamp":1501570024381,"status":403,"error":"Forbidden","message":"Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.","path":"/helpdesk/logout"}
here is my angular logout function:
$scope.logout = function() {
$http.post('logout',{}).success(function() {
$rootScope.authenticated = false;
$location.path("/home");
}).error(function(data) {
$rootScope.authenticated = false;
});
}
here is my SpringSecurityConfig configure method:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.httpBasic().and()
.authorizeRequests()
.antMatchers("/index.html","/pages/**","/","/webjars/**")
.permitAll()
.anyRequest()
.authenticated().and().logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll()
.logoutSuccessHandler(logoutSuccess)
.deleteCookies("JSESSIONID").invalidateHttpSession(false)
.and()
.addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class);
}
How can I solve this? How can I add token header to all request? Could you help me please?