I have CKeditor on my jsp and whenever I upload something, the following error pops out:
Refused to display 'http://localhost:8080/xxx/xxx/upload-image?CKEditor=text&CKEditorFuncNum=1&langCode=ru' in a frame because it set 'X-Frame-Options' to 'DENY'.
I have tried removing Spring Security and everything works like a charm. How can I disable this in spring security xml file? What should I write between <http>
tags
By default
X-Frame-Options
is set to denied, to prevent clickjacking attacks. To override this, you can add the following into your spring security configHere are available options for policy
For more information take a look here.
And here to check how you can configure the headers using either XML or Java configs.
Note, that you might need also to specify appropriate
strategy
, based on needs.If you're using Spring Boot, the simplest way to disable the Spring Security default headers is to use
security.headers.*
properties. In particular, if you want to disable theX-Frame-Options
default header, just add the following to yourapplication.properties
:There is also
security.headers.cache
,security.headers.content-type
,security.headers.hsts
andsecurity.headers.xss
properties that you can use. For more information, take a look atSecurityProperties
.Most likely you don't want to deactivate this Header completely, but use
SAMEORIGIN
. If you are using the Java Configs (Spring Boot
) and would like to allow the X-Frame-Options:SAMEORIGIN
, then you would need to use the following.For older Spring Security versions:
For newer versions like Spring Security 4.0.2:
If you're using Java configs instead of XML configs, put this in your "WebSecurityConfigurerAdapter.configure(HttpSecurity http)" method:
If you are using Spring Security's Java configuration, all of the default security headers are added by default. They can be disabled using the Java configuration below:
If using XML configuration you can use