점프투 스프링부트 3-05) 스프링 시큐리티 설정에 대해 질문 있습니다.
안녕하세요 저는 지금 마리아 db를 이용해서 프로젝트를 만들어 보고 있는데요 그래서 h2 콘솔이 아닌 마리아 db를 사용하고 있다면
아래에서 .csrf().ignoringAntMatchers("/h2-console/**") 이 부분만 수정하면 되는건가요?
package com.mysite.sbb;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter;
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/").permitAll()
.and()
.csrf().ignoringAntMatchers("/h2-console/")
.and()
.headers()
.addHeaderWriter(new XFrameOptionsHeaderWriter(
XFrameOptionsHeaderWriter.XFrameOptionsMode.SAMEORIGIN))
;
return http.build();
}
}
fpswj4676 님 347
2022년 8월 25일 11:25 오후