Skip to content

Commit c81a3d9

Browse files
authored
Update SecurityConfig.java
1 parent 675bb15 commit c81a3d9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/com/example/FixLog/config/SecurityConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.example.FixLog.repository.MemberRepository;
44
import com.example.FixLog.util.JwtUtil;
5+
import com.example.FixLog.filter.JwtAuthenticationFilter;
56
import jakarta.servlet.Filter;
67
import lombok.RequiredArgsConstructor;
78
import org.springframework.context.annotation.Bean;
@@ -10,6 +11,7 @@
1011
import org.springframework.security.authentication.AuthenticationManager;
1112
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
1213
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
14+
import org.springframework.security.config.Customizer;
1315
import org.springframework.security.web.SecurityFilterChain;
1416
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1517
import 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

Comments
 (0)