package security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

import javax.sql.DataSource;

@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private DataSource dataSource;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .csrf().and()
            .authorizeRequests()
                .antMatchers("/").permitAll()
                .antMatchers("/api/login").permitAll()
                .anyRequest().authenticated()
                .and()
            .formLogin()
                .loginPage("/login")
                .permitAll()
                .and()
            .logout()
                .logoutUrl("/logout")
                .deleteCookies("remember-me")
                .logoutSuccessUrl("/login?logout")
                .permitAll()
                .and()
            .rememberMe();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.jdbcAuthentication().dataSource(this.dataSource);
    }
}

@@ -106,165 +106,40 @@
 ork.
-boot.autoconfigure.security.SecurityProperties;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.core.annotation.Order
+context.annotation.Configuration
 ;%0Aim
@@ -532,84 +532,8 @@
 ity;
-%0Aimport org.springframework.security.web.util.matcher.AntPathRequestMatcher;
 %0A%0Aim
@@ -817,34 +817,8 @@
 ttp%0A
-            .csrf().and()%0A
     
@@ -1156,143 +1156,8 @@
 t()%0A
-                .logoutUrl(%22/logout%22)%0A                .deleteCookies(%22remember-me%22)%0A                .logoutSuccessUrl(%22/login?logout%22)%0A
     
@@ -1351,16 +1351,29 @@
     auth
+%0A            
 .jdbcAut
@@ -1385,16 +1385,33 @@
 cation()
+%0A                
 .dataSou

Remove Unnecessary Clutter from WebSecurityConfig