【问题标题】:X-Frame-Options are not working correct for meX-Frame-Options 不适合我
【发布时间】:2018-11-24 05:43:18
【问题描述】:

我在 tomcat+java+servlets 上有后端(localhost:8080)。 js前端(localhost:8081)。

我尝试使用 iframe(在 iframe 中插入一些内容)(localhost:8081)

所以, 1)如果像这样添加过滤器

`response.addHeader("X-Frame-Options", "ALLOW FROM http://localhost:8080");`

- 工作正常,但它是安全的差距。

2) 如果这样使用

response.addHeader("X-Frame-Options", "ALLOW FROM http://localhost:8081"); 
response.setHeader("Access-Control-Allow-Headers", "x-requested-with");

-不适用于浏览器中的错误消息:

拒绝显示 'http://localhost:8081/app/jsf/payments.jsf?hide=true' 在一个框架中 因为它设置了多个具有冲突的“X-Frame-Options”标头 值('拒绝,允许来自http://localhost:8081')。回落到 '拒绝'。

【问题讨论】:

    标签: java servlets


    【解决方案1】:

    需要使用 response.setHeader("Content-Security-Policy", "frame-ancestors http://localhost:8081");

    X-Frame-Options 已弃用。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-10
    • 2014-02-11
    • 1970-01-01
    • 2014-10-08
    • 2017-12-07
    • 2016-09-17
    • 2017-06-13
    • 2013-06-10
    相关资源
    最近更新 更多