Closed JinhwanB closed 6 months ago
아래 코드 추가 후 정상 접근 가능
@Slf4j
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
@RequiredArgsConstructor
public class SecurityConfiguration {
private final JwtAuthenticationFilter authenticationFilter;
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.csrf(csrf -> csrf.ignoringRequestMatchers("/h2-console/**")
.disable()) // 변경
.httpBasic(AbstractHttpConfigurer::disable)
.sessionManagement(sessionManagement ->
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(authorizeRequest ->
{
authorizeRequest
.requestMatchers(
new AntPathRequestMatcher("/**/signin"),
new AntPathRequestMatcher("/**/signup"),
new AntPathRequestMatcher("/h2-console/**")
).permitAll();
})
.addFilterBefore(authenticationFilter, UsernamePasswordAuthenticationFilter.class)
.headers(
headersConfigurer ->
headersConfigurer.frameOptions(
HeadersConfigurer.FrameOptionsConfig::disable
)
); // 추가
return http.build();
}
}
프로젝트에 시큐리티 적용 후 h2 에 시큐리티에서 접근을 허용하지 않는 현상 발생 (h2-console경로에 permitAll을 해놓은 상태였음)