![](/img/trans.png)
[英]Spring Boot Actuator adding X-Frame-Options = DENY to all endpoints (particularly error endpoint)
[英]X-Frame-Options: DENY works only on backend port endpoints
因此,由於我正在處理 spring 安全性,因此我已將 headers.frameOptions 設置為 DENY,當我通過將后端端點放入 iframe(此處為localhost:8080 )來嘗試此操作時,一切都運行良好,問題是,當我將前端localhost:3000放在 iframe 中,沒有任何反應,應用程序顯示在 iframe 中。我認為我正在做的標頭配置僅適用於 API,而不適用於應用程序的開始
在應用程序開始時,您可以看到沒有配置: X-Frame-Options: DENY在我發送 API 之后
這是 function
@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers()
.httpStrictTransportSecurity()
.maxAgeInSeconds(31536000)
.includeSubDomains(true);
http.headers()
.contentTypeOptions();
http.cors().and()
.headers()
.xssProtection()
.and()
.contentSecurityPolicy("script-src 'self'")
.and()
.httpStrictTransportSecurity().includeSubDomains(true).maxAgeInSeconds(31536000)
.and()
.contentSecurityPolicy("frame-ancestors 'none'")
.and()
.frameOptions()
.deny()
.and()
.csrf()
.disable()
.formLogin().defaultSuccessUrl("/swagger-ui.html", true).and()
.authorizeRequests().antMatchers(AUTH_LIST).authenticated()
.antMatchers("/actuator/**").access("hasAnyRole('ADMIN') and hasIpAddress('127.0.0.1')")
.anyRequest().permitAll()
.and().httpBasic();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.