springBoot springSecurty x-frame-options deny


spring Security下,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();    

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM