java - SpringBoot:只允许特定网站上我的应用的某些页面在Iframe中
问题描述
我正在使用带有 spring security 和 thymleaf 的 jdk8、springboot(v2.0.3)。我想在 iframe 中的特定网站上允许我的一些应用程序页面。
http
.headers()
.frameOptions().disable()
.and()
.csrf().disable()/*disbaling csrf here*/
.authorizeRequests()
.antMatchers("/","/login","/css/**", "/js/**", "/fonts/**","/img/**").permitAll()/*do not use spring security on this path*/
.and()
.formLogin()
.successHandler(successHandler) /*after success login on web we are handling the success event*/
.permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login/?logout") /*defining logout and login url here*/
.permitAll()
以上是我正在使用的示例代码。现在它已禁用 iframe。我希望它为特定网站启用,例如 https://abc.yxv.com、https://bac.xyz.com 等。
我在某些地方读到 x-frame-options 现在已弃用或不是一个好方法,因为它不支持现代浏览器。请帮助我。什么是这样做的好方法和代码示例
谢谢
解决方案
推荐阅读
- sql - SQL根据ID将一张表拆分为两张表
- android - 如何在android中改变芯片组件的形状?
- mysql - 在 Mysql 中使用 VARCHAR
- javascript - 如何在浏览器的 Javascript 中使用 mongodb-stitch-browser-sdk 的 StitchAppClientConfiguration?
- python - 如何将变量附加到列表而不是其内容
- django - 无法从 Django 管理员显示图像
- c - 如何使用 mmap 共享部分内存
- udp - 对 2 个 Pycom 微处理器 (Micropython) 之间的简单 UDP 连接进行故障排除
- web-scraping - 具有正常值的延迟计算结束链
- flutter - 如何在底部导航上方制作颤振抽屉