11package org .example .soundlinkchat_java .global .config ;
22
3- import jakarta .servlet .ServletRequest ;
43import lombok .RequiredArgsConstructor ;
54import org .example .soundlinkchat_java .global .auth .JwtAuthenticationFilter ;
65import org .example .soundlinkchat_java .global .auth .JwtProvider ;
98import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
109import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
1110import org .springframework .security .config .annotation .web .configurers .AbstractHttpConfigurer ;
11+ import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
1212import org .springframework .security .web .SecurityFilterChain ;
1313import org .springframework .security .web .authentication .UsernamePasswordAuthenticationFilter ;
1414
1515@ Configuration
1616@ EnableWebSecurity
1717@ RequiredArgsConstructor
18+ @ SuppressWarnings ("squid:S4502" )
1819public class SecurityConfig {
19-
2020 private final JwtProvider jwtProvider ;
2121
2222 @ Bean
23- public SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
23+ public BCryptPasswordEncoder passwordEncoder () {
24+ return new BCryptPasswordEncoder ();
25+ }
26+
27+ @ Bean
28+ public SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
2429 http
25- .csrf (csrf -> csrf
26- .requireCsrfProtectionMatcher (ServletRequest ::isSecure ) // HTTPS만 CSRF 보호 적용
27- )
30+ .csrf (AbstractHttpConfigurer ::disable )
2831 .authorizeHttpRequests (auth -> auth
2932// .requestMatchers("/api/**").permitAll()
3033// .requestMatchers("/swagger-ui/**").permitAll()
@@ -36,7 +39,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3639 // JwtAuthenticationFilter 추가
3740 .addFilterBefore (new JwtAuthenticationFilter (jwtProvider ), UsernamePasswordAuthenticationFilter .class );
3841
39-
4042 return http .build ();
4143 }
42- }
44+ }
0 commit comments