Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RubyonRails允许使用frame内容安全策略或X-frame-Options将您的网站嵌入其他网站_Ruby On Rails_Google Chrome_Iframe_Content Security Policy_X Frame Options - Fatal编程技术网

Ruby on rails RubyonRails允许使用frame内容安全策略或X-frame-Options将您的网站嵌入其他网站

Ruby on rails RubyonRails允许使用frame内容安全策略或X-frame-Options将您的网站嵌入其他网站,ruby-on-rails,google-chrome,iframe,content-security-policy,x-frame-options,Ruby On Rails,Google Chrome,Iframe,Content Security Policy,X Frame Options,我正在尝试允许其他人在许多网站上嵌入我的rails应用程序中的页面。我可以使用X-Frame-Options在Chrome和Firefox中使用它。是否有等效的内容安全策略 response.headers['X-Frame-Options']=“ALLOW-FROM*” 这是使用X帧选项的位 class PeopleController < ApplicationController def embed response.headers['X-Frame-Options']

我正在尝试允许其他人在许多网站上嵌入我的rails应用程序中的页面。我可以使用X-Frame-Options在Chrome和Firefox中使用它。是否有等效的内容安全策略
response.headers['X-Frame-Options']=“ALLOW-FROM*”

这是使用X帧选项的位

class PeopleController < ApplicationController
  def embed
    response.headers['X-Frame-Options'] = "ALLOW-FROM *"
    @company = People.new
  end
end
这是嵌入代码的一个示例:

  <iframe src="http://localhost:3000/people/embed"></iframe>

现代Chrome和Firefox不支持
X-Frame-Options
标题中的
ALLOW-FROM
键。您可以发布
X-Frame-Options:ALLOW-FROM
X-Frame-Options:ALLOW-FROMhttp://example.com
-它们不限制任何内容,带有
ALLOW-FROM
键的标题只能被浏览器忽略

如果您希望允许无限域的iframing,那么根本不发布
X-Frame-Options
标题(和
Frame-concedens
指令)就更容易了

如果您有一组已计数的允许域,则可以将CSP头与
帧祖先域1域2一起使用。。。域

使用内容安全策略时,它会抛出以下错误:
。。。因为祖先违反了以下内容安全策略指令:“框架祖先自身”

此错误意味着您确实发布了
帧祖先“自我”
,而不是
帧祖先“自我”*

可能您同时发布了两个不同的CSP头,可能代码中有错误。您可以在浏览器中查看实际获得的CSP头

注1
'self'
标记应为单引号-在代码中使用
“'self'”
字符串


注意2
'self'
令牌通常仅包括标准端口80/443,不包括
http://localhost:3000
(取决于浏览器)。星号
*
确实包含任何端口号。

根据您的建议,我在控制器上尝试了response.headers.delete“X-Frame-Options”,但表单提交仅适用于Firefox,在Chrome上失败,除非我在控制器上添加skip\u before\u操作:验证\u真实性\u令牌这不是CSP相关问题
无法在与
http相关的Chrome中验证CSRF令牌的真实性
用法,而不是
https:
firefoxhttp到https。但铬却不行。人们通常使用
proxy\u set\u头X-Forwarded-Proto$方案在Nginx中,但首先必须尝试清除Crome浏览器缓存和coockie,
Refused to frame 'http://localhost:3000/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors self".
  <iframe src="http://localhost:3000/people/embed"></iframe>
  <iframe src="/people/embed"></iframe>

content_security_policy do |p|
  p.frame_ancestors 'self', "*"
end