22
33import com .example .FixLog .repository .MemberRepository ;
44import com .example .FixLog .util .JwtUtil ;
5+ import com .example .FixLog .filter .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,14 +28,14 @@ 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
3033 .requestMatchers (HttpMethod .POST , "/members/signup" ).permitAll ()
3134 .requestMatchers (HttpMethod .POST , "/auth/login" ).permitAll ()
3235 .requestMatchers (HttpMethod .GET , "/members/check-email" ).permitAll ()
3336 .requestMatchers (HttpMethod .GET , "/members/check-nickname" ).permitAll ()
3437 .requestMatchers (HttpMethod .GET , "/h2-console/**" ).permitAll ()
35- //배포 확인용 임시 수정
36- .requestMatchers (HttpMethod .GET , "/test" , "/test/**" ).permitAll ()
38+ .requestMatchers (HttpMethod .GET , "/test" , "/test/**" ).permitAll () // 테스트용 허용
3739 .anyRequest ().authenticated ()
3840 )
3941 .headers (headers -> headers .frameOptions (frame -> frame .disable ())) // H2 콘솔용
@@ -52,7 +54,6 @@ public PasswordEncoder passwordEncoder() {
5254 return new BCryptPasswordEncoder ();
5355 }
5456
55- // 인증 매니저 (선택: 로그인 시 AuthenticationManager 사용 가능)
5657 @ Bean
5758 public AuthenticationManager authenticationManager (AuthenticationConfiguration config ) throws Exception {
5859 return config .getAuthenticationManager ();
0 commit comments