포트폴리오 프로젝트 진행 중 SmartEditor를 사용하려고 했더니

 

Refused to display 'http://localhost:8080/insert' in a frame because it set 'X-Frame-Options' to 'deny'

 

이런 오류가 chorme 개발자 도구 console창에서 확인.

 

기존에 thehouse 프로젝트 진행하면서 분명 이거 어디 정리해놨던 기억이 있는데 블로그 게시글에 전혀 보이질 않아서

다시 작성.

 

Spring Security에서는 보안상의 이슈로 인해 X-Frame 을 default로 차단하도록 되어있다.

 

X-Frame-Option을 비활성화 하게 되면 보안 이슈가 발생할 수 있기 때문에 

동일 도메인에서는 iframe 접근이 가능하도록 sameOrigin으로 설정하면 된다

 

http.headers().frameOptions().sameOrigin();

 

아예 비활성화하는 방법은

http.headers().frameOptions().disable();

 

Spring Boot에서는 Properties에 작성할수도 있다.

security.headers.frame = false

 

 

xml형태로 작성한 security-config에서는 

<http auto-config="true" use-expressions="true>
  <headers>
    <frame-options policy="SAMEORIGIN"/>
  </headers>

 

이렇게 작성해주면 된다.

+ Recent posts