@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
private CustomAuthenticationProvider customAuthenticationProvider;

    @Override
protected void configure(HttpSecurity http) throws Exception {

      http.authorizeRequests().antMatchers("/health_check", "/health_check/**").permitAll();


      http.antMatcher("/api/v1/**").authorizeRequests().anyRequest().authenticated().and().addFilterBefore(new AuthenticationSessionFilter(), BasicAuthenticationFilter.class);

      http.csrf().disable();

    }

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

}