TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Reminder: secret_token.rb is named so for a reason

53 点作者 Ryoku超过 12 年前

10 条评论

JPKab超过 12 年前
Wow. Please, please tell me that these are just hobby projects which have this happening. I can understand a beginner who doesn't understand git ignore doing this, but if there are people building products with this ignorance, that is troubling. I can see why a lot of greybeards hate frameworks, because someone who builds web apps with a much more bare bones framework, (Sinatra, Webapp2, Express, etc) most likely understands the fundamentals of encryption/hashing simply because of the fact that lighter frameworks require understanding the fundamentals in general.<p>This isn't to say that a developer for one of these frameworks couldn't easily overlook adding the files with secret_tokens in them to the .gitignore.
评论 #4970498 未加载
评论 #4971076 未加载
评论 #4970173 未加载
cllns超过 12 年前
It'd be nice if github would suggest adding secret_token.rb to .gitignore when it's uploaded.
评论 #4970179 未加载
评论 #4970525 未加载
评论 #4970324 未加载
评论 #4970471 未加载
评论 #4971207 未加载
omra超过 12 年前
Note that this was published back in May 2012, so it's not entirely recent (which is OK, just thought I would note it). However, this seems to have been public by February 2011 (<a href="http://stackoverflow.com/questions/5132152/when-you-have-secret-key-in-your-project-how-can-pushing-to-github-be-possible" rel="nofollow">http://stackoverflow.com/questions/5132152/when-you-have-sec...</a>). I don't think the issue is entirely widespread, and a different key is likely used for production.
评论 #4970353 未加载
bgdam超过 12 年前
What is the advantage to hashing a user id and storing it in the cookie over simply generating a random session code and storing it in a db table against the user's id and then checking every request? Is the overhead of an extra db read the only reason people don't do this? (Honest question, not trying to be smart)
评论 #4971071 未加载
评论 #4971660 未加载
评论 #4970586 未加载
joevandyk超过 12 年前
Why don't more people keep configuration / api keys / etc in the database?<p>1. Your configuration is backed up along with your data.<p>2. You can share configuration with multiple applications easily.<p>3. Use postgresql's LISTEN/NOTIFY to tell your applications about new configuration changes in real-time.<p>4. Your configuration is as secret as your data.
评论 #4971261 未加载
评论 #4971545 未加载
bgentry超过 12 年前
As hgimenez said, the best way is to not store your secrets in your source tree at all (12factor.net style). Keep them in the environment. Here's a great example:<p><a href="https://github.com/democrats/voter-registration/commit/2fa8796658fdbf18490cd2a3d7bf173e53b1cab8" rel="nofollow">https://github.com/democrats/voter-registration/commit/2fa87...</a>
评论 #4971092 未加载
juandazapata超过 12 年前
We use the Figaro gem to setup ENV variables per project without messing with your system Path.<p>It also pushes your ENV vars to Heroku with one command. Pretty neat and simple.<p>In case you want to check it out <a href="https://github.com/laserlemon/figaro" rel="nofollow">https://github.com/laserlemon/figaro</a>
prezjordan超过 12 年前
Why doesn't rails add this to the .gitignore generated from `rails new myapp`? And maybe include a rake task to generate a new secret token. That's why I've been doing ever since I found out about this.
评论 #4971016 未加载
michaelmior超过 12 年前
I would argue this is even worse for Django projects. Django secret keys are in the settings file by default, which definitely needs to be put under revision control.
maximegarcia超过 12 年前
Exactly!<p><a href="https://github.com/LePartiDeGauche/pgonror/issues/2" rel="nofollow">https://github.com/LePartiDeGauche/pgonror/issues/2</a>