ich jquery download plugin in meinem Frühjahr Projekt bin mit aber Browser geben Sie mir folgende Fehlermeldung:X-Frame DENY im Frühjahr Sicherheit
Refused to display 'http://localhost:8086/DART/fleetAndCar/download/5' in a frame because it set 'X-Frame-Options' to 'DENY'.
Ich lese ein Problem über Xframe im Frühjahr Sicherheit so habe ich hinzugefügt
http
.headers()
.addHeaderWriter(new XFrameOptionsHeaderWriter(XFrameOptionsHeaderWriter.XFrameOptionsMode.SAMEORIGIN))
aber es ändert sich nicht leugnen, aber für noch SAMEORIGIN so habe ich, dass er Fehler folgende:
Multiple 'X-Frame-Options' headers with conflicting values ('DENY, SAMEORIGIN') encountered when loading 'http://localhost:8086/DART/fleetAndCar/download/5'. Falling back to 'DENY'.
und das ist die HTTP-Anfrage:
dies ist meine Federkonfiguration:
@Configuration
@Order(1)
public static class ApiWebSecurityConfig extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.antMatcher("/client/**")
.authorizeRequests()
//Exclude send file from authentication because it doesn't work with spring authentication
.antMatchers(HttpMethod.POST, "/client/file").permitAll()
.anyRequest().authenticated()
.and()
.httpBasic();
}
}
@Configuration
@Order(2)
public static class FormWebSecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
RoleServices roleServices;
@Override
public void configure(WebSecurity web) throws Exception {
web
//Spring Security ignores request to static resources such as CSS or JS files.
.ignoring()
.antMatchers("/static/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
List<Role> roles=roleServices.getRoles();
//Retrieve array of roles(only string field without id)
String[] rolesArray = new String[roles.size()];
int i=0;
for (Role role:roles){
rolesArray[i++] = role.getRole();
}
http
.headers()
.addHeaderWriter(new XFrameOptionsHeaderWriter(XFrameOptionsHeaderWriter.XFrameOptionsMode.SAMEORIGIN))
.and()
.authorizeRequests() //Authorize Request Configuration
.anyRequest().hasAnyRole(rolesArray)//.authenticated()
.and() //Login Form configuration for all others
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.exceptionHandling().accessDeniedPage("/403")
.and()
.logout()
.logoutSuccessUrl("/login?logout")
.permitAll();
}
}
Wie kann ich dieses Problem beheben Dank (der Download funktioniert trotz des Fehlers fein)
könnten Sie uns weitere Details im Zusammenhang mit Ihrem Code bereitstellen. ? Vielen Dank – Robert
Es ist eine gute Übung auf Stack Overflow, eine Erklärung hinzuzufügen, warum Ihre Lösung funktionieren sollte. Für weitere Informationen lesen Sie [Wie Sie antworten] (// stackoverflow.com/help/how-to-answer). –