package ee.pardiralli.configuration;

import ee.pardiralli.security.WpPasswordHash;
import lombok.AllArgsConstructor;
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.core.userdetails.UserDetailsService;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;


@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
@AllArgsConstructor(onConstructor = @__(@Autowired))
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    private UserDetailsService userDetailsService;

    /**
     * Set pages that do not need authentication such as index or login and deny access to other pages.
     * Also set login and logout pages.
     */
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers(
                        "/",
                        "/login",
                        "/banklink/**").permitAll().anyRequest()
                .fullyAuthenticated().and().formLogin().loginPage("/login")
                .failureUrl("/login?error").and().logout()
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout")).and()
                .csrf().ignoringAntMatchers("/banklink/**");
    }

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth
                .userDetailsService(userDetailsService)
                .passwordEncoder(new WpPasswordHash());
    }
}

@@ -1352,38 +1352,13 @@
 ers(
-%0A                        
 %22/%22,%0A
+
     
@@ -1451,33 +1451,16 @@
 equest()
-%0A                
 .fullyAu
@@ -1478,16 +1478,33 @@
 ().and()
+%0A                
 .formLog
@@ -1527,33 +1527,16 @@
 /login%22)
-%0A                
 .failure
@@ -1564,17 +1564,8 @@
 nd()
-.logout()
 %0A   
@@ -1577,16 +1577,25 @@
         
+.logout()
 .logoutR

Refactor SecurityConfiguration