title: spring boot angular js http:/localhost:8080/logout 403 forbidden error
body: <p>I couldn't solve this issue.</p>
  
  <p>I try to athentication login logout example <a href="https://spring.io/blog/2015/01/12/the-login-page-angular-js-and-spring-security-part-ii" rel="nofollow noreferrer">here</a>. Login is work properly but when I try to logout, browser gives NetworkError : 403 forbidden localhost:8080/logout is forbidden.</p>
  
  <p>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?</p>
  
  <p>here is the browser developer tools message :</p>
  
  <blockquote>
    <p>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"}</p>
  </blockquote>
  
  <p>here is my angular logout function:</p>
  
  <pre><code> $scope.logout = function() {
      $http.post('logout',{}).success(function() {
        $rootScope.authenticated = false;
        $location.path("/home");
      }).error(function(data) {
        $rootScope.authenticated = false;
      });
    }
  </code></pre>
  
  <p>here is my SpringSecurityConfig configure method:</p>
  
  <pre><code> @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);
  
  }
  </code></pre>
  
  <p>How can I solve this? How can I add token header to all request? Could you help me please?</p>