22
33import com .example .FixLog .repository .MemberRepository ;
44import com .example .FixLog .util .JwtUtil ;
5+ import com .example .FixLog .config .JwtAuthenticationFilter ;
56import jakarta .servlet .Filter ;
67import lombok .RequiredArgsConstructor ;
78import org .springframework .context .annotation .Bean ;
1011import org .springframework .security .authentication .AuthenticationManager ;
1112import org .springframework .security .config .annotation .authentication .configuration .AuthenticationConfiguration ;
1213import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
14+ import org .springframework .security .config .Customizer ;
1315import org .springframework .security .web .SecurityFilterChain ;
1416import org .springframework .security .web .authentication .UsernamePasswordAuthenticationFilter ;
1517import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
@@ -26,10 +28,12 @@ public class SecurityConfig {
2628 public SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
2729 http
2830 .csrf (csrf -> csrf .disable ())
31+ .cors (Customizer .withDefaults ()) // CORS 설정 추가 (WebConfig와 연결됨)
2932 .authorizeHttpRequests (auth -> auth
30- // 비로그인 허용 경로
33+ .requestMatchers (HttpMethod .GET , "/auth/**" ).permitAll ()
34+ .requestMatchers (HttpMethod .POST , "/auth/**" ).permitAll ()
35+
3136 .requestMatchers (HttpMethod .POST , "/members/signup" ).permitAll ()
32- .requestMatchers (HttpMethod .POST , "/auth/login" ).permitAll ()
3337 .requestMatchers (HttpMethod .GET , "/members/check-email" ).permitAll ()
3438 .requestMatchers (HttpMethod .GET , "/members/check-nickname" ).permitAll ()
3539 .requestMatchers (HttpMethod .GET , "/search/**" ).permitAll ()
@@ -39,6 +43,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3943 // 배포 확인용 임시 허용
4044 .requestMatchers (HttpMethod .GET , "/test" , "/test/**" ).permitAll ()
4145 // 그 외 모든 요청은 인증 필요
46+ .requestMatchers (HttpMethod .GET , "/test" , "/test/**" ).permitAll () // 테스트용 허용
47+
4248 .anyRequest ().authenticated ()
4349 )
4450 .headers (headers -> headers .frameOptions (frame -> frame .disable ())) // H2 콘솔
0 commit comments