Security 적용 후에 막
이런게 나옴. 찾아보니
X-Frame-Options 때문이라고 함.
spring security를 적용하면 기본적으로 X-Frame-Options Click jacking 공격 막기 설정이 되어있기 때문이었다.
https://developer.mozilla.org/ko/docs/Web/HTTP/Headers/X-Frame-Options
X-Frame-Options - HTTP | MDN
The X-Frame-Options HTTP 응답 헤더는 해당 페이지를 <frame> 또는<iframe>, <object> 에서 렌더링할 수 있는지 여부를 나타내는데 사용됩니다. 사이트 내 콘텐츠들이 다른 사이트에 포함되지 않도록 하여
developer.mozilla.org
X-Frame-Options 종류로는 아래 3가지가 있는데 이번 오류는 SAMEORIGIN 옵션을 사용해서 해결할 것이다.
- DENY : 해당 페이지는 frame을 표시할 수 없음
- SAMEORIGIN : 해당 페이지와 동일한 orgin에 해당하는 frame만 표시할 수 있음
- ALLOW-FROM uri : 해당 페이지는 지정된 orgin에 해당하는 frame만 표시할 수 있음
해결법
X-Frame-Options 를 비활성화 하는 설정이지만 보안적인 이슈가 발생할 수 있습니다.
http.headers().frameOptions().disable();
동일 도메인에서는 iframe 접근이 가능하도록 X-Frame-Options를 sameOrigin() 으로 설정하면 됩니다.
http.headers().frameOptions().sameOrigin();
Java로 간단하게 설정이 가능하지만 Spring Boot 에서는 강력한 properties 파일로 설정이 가능합니다.
security.headers.frame = false
Spring 에서는
따라서 이와 관련된 설정을 해주어야 한다. spring security관련해서 설정한 xml 파일에서 <http auto-config='true' use-expressions="true"> 태그 밑에 표시한 부분을 추가해주면 된다.
<http auto-config='true' use-expressions="true">
<!-- 여기부터 -->
<headers>
<frame-options policy="SAMEORIGIN"/>
</headers>
<!-- 여기까지 추가-->
....
</http>
Spring Boot
만일 Spring Boot를 사용한다면 xml 파일이 아닌 이와 관련된 Java파일로 설정을 할 것이다. 이 경우에는 아래와 같이 하면 되는 것 같은데 정확히 실행해보지 않았지만 핵심은 http.headers().frameOptions().sameOrigin()을 사용하는 것 같다.
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// ...
.headers()
.frameOptions().sameOrigin();
}
}
해주면 됨.
나는 아래로 해결함.
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.headers()
.frameOptions().sameOrigin();
}
https://computer-science-student.tistory.com/497
[스프링, Spring] spring security 적용 후 Refused to display in a frame because it set 'X-Frame-Options' to 'DENY' 발생
spring security 적용 후 Refused to display in a frame because it set 'X-Frame-Options' to 'DENY' 발생 spring 프로젝트에 naver smarteditor2를 적용하려고 하니 Refused to display "http:..
computer-science-student.tistory.com
https://gigas-blog.tistory.com/124
[Spring] Spring Security에서 'X-Frame-Options'응답 헤더 설정
Spring Boot 2.x 로 개발을 하다보면 어마어마한 문제들이 많이 발생합니다. 최근 보안정책을 준수하기 때문에 일반적으로 사용이 가능한 부분들도 보안취약점으로 구분되기도 하죠. 이번에도 Virtua
gigas-blog.tistory.com