5154

Rails 环境搭建,提示安全警告

新手问题Guest • 于发布 • 最后由 lonely21475回复 • 1608次阅读

照着教程搭建了Rails的环境,能够正常运行,但是会但一个警告,如下:
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.

    Called from: /home/soledad/.rvm/gems/ruby-1.9.3-p362/gems/actionpack-3.2.10/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

服务器是正常允许的,rails是3.2.10版本,想请教一下,是不是配置有些什么问题?

共收到 3 条回复
186d5420364f43c606f5150ceaa5241a

stackoverflow已经有讨论,无需修正,或者硬要修的话,修改/home/soledad/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.10/lib/action_dispatch/middleware/session目录下的abstract_store.rb,插一行即可:

    module Compatibility
      def initialize(app, options = {})
        options[:key] ||= '_session_id'
        options[:secret] ||= Rails.application.config.secret_token # insert this line, only a temp solution
        super
      end
5154

非常感谢

9484

正好遇到这个问题,收下了,哈哈

需要 登录 后回复方可回复, 如果你还没有账号你可以 注册 一个帐号。