title: Logout doesn't work with Spring Boot and Spring Security
body: <p>This is my code using Spring Boot and Spring Security. The problem is when I used to logout (using <em>Thyemleaf</em>) the logout doesn't work for me.</p>
  
  <pre class="lang-java prettyprint-override"><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter{
  
      @Autowired
      private DataSource dataSource;
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  
          auth
              .jdbcAuthentication()
                  .dataSource(dataSource)
                  .usersByUsernameQuery("select username as principal, password as credentials,active from users where username=?")
                  .authoritiesByUsernameQuery("select username as principal,roles as role from users_roles where username=?")
                  .rolePrefix("ROLE_")
                  .passwordEncoder(new Md5PasswordEncoder());
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
              .formLogin()
                  .loginPage("/login");
          http
              .authorizeRequests()
                  .antMatchers("/index1").permitAll();
          http
              .authorizeRequests()
                  .antMatchers("/user").hasRole("USER")
                  .and()
              .logout();
  
          http
              .authorizeRequests()
                  .antMatchers("/adpage").hasRole("ADMIN");
          http
              .exceptionHandling().accessDeniedPage("/403");
          http
              .logout().permitAll();
      }
  }
  </code></pre>
  
  <p>Link using Thyemleaf:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;li&gt;&lt;a th:href="@{/login?logout}"&gt;logout&lt;/a&gt;&lt;/li&gt;
  </code></pre>