我正在尝试理解内容安全策略框架祖先标签

Nav*_*ick 3 security content-security-policy ionic-framework ionic3

我正在尝试在 IONIC 应用程序内的 iframe 中显示我的网站之一。我需要限制我的网站被其他网站嵌入框架。我决定使用内容安全策略响应标头,其中

Content-security-policy: frame-ancestors ${website-to-be-allowed}

确保只有提到的网站可以 iframe 我的网站,但是我也需要我的 ionic 应用程序来 iframe 我的网站,并且由于 Ionic 应用程序用作文件系统,我可以将所有文件系统的访问权限授予 iframe 我的网站。当我添加

Content-security-policy: frame-ancestors ${website-to-be-allowed} filesystem

如此处所述, https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors

我在 Android 和 IOS 应用程序上进行了测试,并且都抛出了相同的错误,内容如下:

Refused to display ${website} in a frame because an ancestor violates the following content security policy directive: "frame-ancestors filesystem"

这是弹出的错误,在此处输入图像描述

Lon*_*zak 7

仅供参考,我使用以下方法让它工作:

file://* filesystem:

因此,整体内容安全策略可能如下所示:

Content-Security-Policy: "...; frame-ancestors 'self' file://* filesystem:;