springBoot springSecurty x-frame-options deny
阿新 • • 發佈:2020-07-02
springSecurity下,X-Frame-Options預設為DENY,非Spring Security環境下,X-Frame-Options的預設大多也是DENY:
DENY:瀏覽器拒絕當前頁面載入任何Frame頁面
SAMEORIGIN:frame頁面的地址只能為同源域名下的頁面
ALLOW-FROM:origin為允許frame載入的頁面地址。
解決辦法:disable x-frame-options 選項
http.authorizeRequests() .antMatchers("/").permitAll() // .anyRequest().authenticated()// 其他地址的訪問均需驗證許可權 .and() .formLogin() .loginPage("/login.html") // 登入頁 .failureUrl("/login-error.html").permitAll() // 禁用frameOptions .and().headers().frameOptions().disable().and() .logout() .logoutSuccessUrl("/public/test/index.html"); ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http.authorizeRequests(); registry.requestMatchers(CorsUtils::isPreFlightRequest).permitAll();