STUDY/Spring
Spring Boot | 스프링 시큐리티 X-Frame-Option 설정
개미606
2020. 11. 14. 16:33
클라이언트 측에서 서버의 서드파티 모듈을 아이프레임으로 띄우려고 할 때 X-Frame-Option 어쩌구 에러 등장
스프링 시큐리티 설정을 수정해주면 된다.
sameOrigin이 가장 안전하겠지만 클라이언트와 서버 도메인이 달라서 부득이하게 disable한 후 허용할 url을 등록해주었다.
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().disable()
.addHeaderWriter(new StaticHeadersWriter("X-FRAME-OPTIONS", "ALLOW-FROM " + /* 허용할 URL입력 */)).and()
...생략
}
}
+) 참고
how do I set X-Frame-Options response header to allow-from value(s) using spring java config?
How do I set X-Frame-Options response header with a value of allow-from using spring java config? http.headers().disable() .addHeaderWriter(new XFrameOptionsHeaderWriter( new
stackoverflow.com