package digital.laboratory.platform.reagent.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.context.SecurityContextHolder;

//@EnableOAuth2Sso
@Configuration

public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {

	@Override
	public void configure(WebSecurity web) {
		SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
		web.ignoring().antMatchers("/", "/static/**", "/static/dist/**", "/hello**", "/favicon.ico**", "/login", "/login-callback", "/v2/**", "/papp/v2/**", "/papp/entrustment/common/**","/reagent/v2/**");
	}

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

		http.csrf().disable()
				.authorizeRequests()
				.antMatchers("/", "/static/**", "/static/dist/**", "/hello**", "/favicon.ico**", "/login", "/login-callback", "/v2/**", "/papp/v2/**", "/papp/entrustment/common/**","/reagent/v2/**").permitAll()
				.anyRequest().permitAll();
	}
}
