加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 在Heroku的Sinatra应用程序中,会话不是通过Dyn

发布时间:2020-12-16 19:48:08 所属栏目:百科 来源:网络整理
导读:这是有道理的.但是,这个问题的一些首选工作是什么? 解决方法 在我的评论中,我建议使用 rack cookie based sessions,但是考虑到这一点,Sinatra会话是Rack cookie会话. 进一步,我found this in the Sinatra docs: To improve security,the session data in t
这是有道理的.但是,这个问题的一些首选工作是什么?

解决方法

在我的评论中,我建议使用 rack cookie based sessions,但是考虑到这一点,Sinatra会话是Rack cookie会话.

进一步,我found this in the Sinatra docs:

To improve security,the session data in the cookie is signed with a session secret. A random secret is generate for you by Sinatra. However,since this secret will change with every start of your application,you might want to set the secret yourself,so all your application instances share it:

set :session_secret,'super secret'

所以看来,每个Heroku dyno都生成一个不同的键,所以不能读每个对话的cookie,你需要指定一个键,所以每个dyno使用相同的键.

而不是为您的源代码添加秘密密钥,您可能更好地设置一个environment variable:

$heroku config:add SESSION_KEY=a_longish_secret_key

然后在你的sinatra应用程序:

enable :sessions
set :session_secret,ENV['SESSION_KEY']

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读