-2

how can I replace the code without using WebSecurityConfigurerAdapter

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Bean
    public UserDetailsService userDetailsService() {
        return new UserDetailsServiceImpl();
    }

    @Bean
    public BCryptPasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public DaoAuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
        authProvider.setUserDetailsService(userDetailsService());
        authProvider.setPasswordEncoder(passwordEncoder());

        return authProvider;
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticationProvider());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .formLogin().permitAll()
                .and()
                .logout().permitAll();
    }
}

I try a lot but I can't fix it. Please help me!

1 Answers1

-2

I have some updates for you

@Configuration
@EnableWebSecurity
public class WebSecurityConfig {
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
    http.
            authorizeHttpRequests()
            .anyRequest()
            .authenticated()
            .and()
            .httpBasic();

    return http.build();
  }
}
Anonymus
  • 138
  • 1
  • 2