package ee.tuleva.onboarding.config;

import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;

@EnableWebSecurity
@EnableOAuth2Client
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
            .requestMatchers(EndpointRequest.to("health")).permitAll()
            .regexMatchers("/", "/health", "/swagger-ui.html", "/authenticate", "/idLogin", "/oauth/token",
                "/notifications/payments").permitAll()
            .anyRequest().authenticated()
            .and()
            .csrf().ignoringAntMatchers("/v1/**", "/authenticate", "/idLogin", "/oauth/token",
            "/notifications/payments");
    }

    @Bean
    PasswordEncoder passwordEncoder() {
        DelegatingPasswordEncoder encoder = (DelegatingPasswordEncoder)
            PasswordEncoderFactories.createDelegatingPasswordEncoder();
        encoder.setDefaultPasswordEncoderForMatches(new BCryptPasswordEncoder());
        return encoder;
    }
}

@@ -510,81 +510,8 @@
 er;%0A
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;%0A
 impo
@@ -654,32 +654,105 @@
 asswordEncoder;%0A
+import org.springframework.security.crypto.password.NoOpPasswordEncoder;%0A
 import org.sprin
@@ -1847,18 +1847,12 @@
 hes(
-new BCrypt
+NoOp
 Pass
@@ -1862,16 +1862,28 @@
 dEncoder
+.getInstance
 ());%0A   

Default is NOOP