diff --git a/src/main/java/com/numberone/backend/config/SecurityConfig.java b/src/main/java/com/numberone/backend/config/SecurityConfig.java new file mode 100644 index 00000000..65c76c6a --- /dev/null +++ b/src/main/java/com/numberone/backend/config/SecurityConfig.java @@ -0,0 +1,32 @@ +package com.numberone.backend.config; + +import lombok.extern.slf4j.Slf4j; +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.WebSecurityCustomizer; +import org.springframework.security.config.annotation.web.configurers.HttpBasicConfigurer; +import org.springframework.security.web.SecurityFilterChain; + +@Slf4j +@Configuration +@EnableWebSecurity +public class SecurityConfig { + + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http + .authorizeHttpRequests((auth) -> auth + .anyRequest().authenticated() // 모든 요청에 대한 인증 처리하도록 설정 + ) + .httpBasic(HttpBasicConfigurer::disable); + return http.build(); + } + + @Bean + public WebSecurityCustomizer webSecurityCustomizer() { + return (web) -> web.ignoring() + .requestMatchers("/*"); // 인증 처리 하지 않을 케이스 + } +}