框架的内容安全策略。 frame-src 与 frame-ancestors
Content security policy for frame. frame-src vs frame-ancestors
frame-src
和 frame-ancestors
的具体作用是什么?该定义表明,为两个指令定义框架的有效内容的目的相同。
什么时候使用哪一个?我能够使用 -
在 iframe
中加载外部域内容
frame-ancestors
和 default-src
规则
frame-src
两者都有效,但无法获得正确的用例。
default-src
、frame-ancestors
和 frame-src
都是 Content-Security-Policy response header.
的一部分
frame-src
限制可以在 iframe
.
中加载的域和页面
The HTTP Content-Security-Policy (CSP) frame-src
directive specifies valid sources for nested browsing contexts loading using elements such as <frame>
and <iframe>
.
例如:如果https://example.com
的网站有Content-Security-Policy: frame-src 'self'
的响应header,它只能加载https://example.com
里面iframes
.
frame-ancestors
限制可以从 iframe
加载的域和页面(类似于 X-Frame-Options
header、but takes precedence over it)。
The HTTP Content-Security-Policy (CSP) frame-ancestors
directive specifies valid parents that may embed a page using <frame>
, <iframe>
, <object>
, <embed>
, or <applet>
.
例如: 如果 https://example.com
的网站有 Content-Security-Policy: frame-ancestors 'self'
的响应 header,它只能 从 https://example.com
.
加载 inside iframes
default-src
作为任何未明确设置的 fetch 指令的默认值 (here is a list of all fetch directives)
The HTTP Content-Security-Policy (CSP) default-src
directive serves as a fallback for the other CSP fetch directives. For each of the following directives that are absent, the user agent will look for the default-src
directive and will use this value for it.
例如: Content-Security-Policy: default-src 'self'
将默认为所有提取指令的值 'self'
。其他指令将不受影响。
注意:由于frame-ancestors
不是fetch指令,设置default-src
不会限制它。需要单独设置。
frame-src
和 frame-ancestors
的具体作用是什么?该定义表明,为两个指令定义框架的有效内容的目的相同。
什么时候使用哪一个?我能够使用 -
iframe
中加载外部域内容
frame-ancestors
和default-src
规则frame-src
两者都有效,但无法获得正确的用例。
default-src
、frame-ancestors
和 frame-src
都是 Content-Security-Policy response header.
frame-src
限制可以在 iframe
.
The HTTP Content-Security-Policy (CSP)
frame-src
directive specifies valid sources for nested browsing contexts loading using elements such as<frame>
and<iframe>
.
例如:如果https://example.com
的网站有Content-Security-Policy: frame-src 'self'
的响应header,它只能加载https://example.com
里面iframes
.
frame-ancestors
限制可以从 iframe
加载的域和页面(类似于 X-Frame-Options
header、but takes precedence over it)。
The HTTP Content-Security-Policy (CSP)
frame-ancestors
directive specifies valid parents that may embed a page using<frame>
,<iframe>
,<object>
,<embed>
, or<applet>
.
例如: 如果 https://example.com
的网站有 Content-Security-Policy: frame-ancestors 'self'
的响应 header,它只能 从 https://example.com
.
iframes
default-src
作为任何未明确设置的 fetch 指令的默认值 (here is a list of all fetch directives)
The HTTP Content-Security-Policy (CSP)
default-src
directive serves as a fallback for the other CSP fetch directives. For each of the following directives that are absent, the user agent will look for thedefault-src
directive and will use this value for it.
例如: Content-Security-Policy: default-src 'self'
将默认为所有提取指令的值 'self'
。其他指令将不受影响。
注意:由于frame-ancestors
不是fetch指令,设置default-src
不会限制它。需要单独设置。