package sklep.security;

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.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
public class SecurityConfig {
	@Bean
	SecurityFilterChain setHttpSecurity(HttpSecurity httpSecurity) throws Exception {
		httpSecurity
			.authorizeHttpRequests((authz) -> authz
					.anyRequest().permitAll()
//					.requestMatchers("/").permitAll()
//					.requestMatchers("/whoami").permitAll()
//					.requestMatchers("/*.css").permitAll()
//					.requestMatchers("/hello", "/time").permitAll()
//					.requestMatchers("/alt?/**").authenticated() // zalogowany jako ktokolwiek
//					.requestMatchers("/products/new", "/products/*/edit").hasAuthority("ROLE_manager")
//					.requestMatchers("/products/**").permitAll()
//					.requestMatchers("/customers/new", "/customers/*/edit").hasAuthority("ROLE_manager")
//					.requestMatchers("/customers/**").authenticated()
//					.anyRequest().denyAll()
				)
			.formLogin();
		return httpSecurity.build();
	}
	
}
