English 中文(简体)
• 如何利用铁路航空基础设施明确保护全球公路货运行动
原标题:How can you use Rails AuthenticityToken infrastructure to explicitly protect a GET action

铁路公司(Ausenticity Token)自动保护从欧洲公路运输组织的攻击中提出的要求。 但我想到的是另一个情况。

我在我的网站上播放了一个录像,我不想在其他地点被渗透。 我的闪电者如何发出要求,要求我的国家航天中心签署一份备忘录,在几秒内结束。 直到现在,用户必须登上录像带,这样作认证。 然而,现在,我希望任何访问者都能够观看录像,而不要允许从另一个地点(例如,如果他们把我们的参与者带进他们的现场)索取已签署的URL。

我首先想到的是Austhenticity Token,因为似乎有这些确切的语义......我需要做的是把它推到GET的要求中。 任何想法?

最佳回答

铁路认为,所有GET申请都应该是站不住脚的。 这意味着铁路当然不会检查GET申请的真伪,甚至经核实。 给每个就业岗位发放通行证。

def verified_request?
  !protect_against_forgery?     ||
    request.method == :get      ||
    !verifiable_request_format? ||
    form_authenticity_token == params[request_forgery_protection_token]
end

因此,我们必须阐述自己的逻辑。 我们可以使用“美容”。 所有这一切都造成了一种任意的扼杀,使本届会议得以 the:

def form_authenticity_token
   session[:_csrf_token] ||= ActiveSupport::SecureRandom.base64(32)
end

因此,我们可以在过滤之前检测到届会的圆顶参数的平等。 通过确保只有杀手的访客才能观看录像。

主计长:

class CDNController < Action主计长::Base
  # You probably only want to verify the show action
  before_filter :verify_request, :only =>  show 

  # Regular controller actions…

  protected

  def verify_request
    # Correct HTTP response code is 403 forbidden, not 404 not found.
    render(:status => 403) unless form_authenticity_token == params[:token]
  end

end

观点:

<%= video_path(:token => form_authenticity_token) %>
问题回答

your弄你的真伪:

<%= video_path(:token => form_authenticity_token) %>

在您的CDN控制器中,你可以检查被证明的真实性是否正确。

def verify_token
    render_404 unless form_authenticity_token == params[:token]
end

def render_404
    render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
end




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签