在 rails 应用程序中放置安全密码/密钥的位置? [英] where to put secure passwords/keys in a rails app?
问题描述
我有一些 Web 服务需要传递安全令牌/密钥/密码.我应该在哪里定义这些安全值以供 Rails 应用程序查看?我想要版本控制中的开发密钥,但不想要版本控制中的生产密钥.我应该如何设置?我是 Rails 新手.
I have a few web services that require secure tokens/keys/passwords to be passed in. Where should I define these secure values for my rails app to see? I want the development keys in version control, but don't want the production keys in version control. How should I set this up? I'm new to rails.
推荐答案
您正确地看到了问题.
将您的passwords
和keys
放在一些从版本控制中排除的 yml 文件中.
Put your passwords
and keys
in some yml file excluded from version control.
然后在您的生产服务器上,创建完全相同的文件,并在每次部署时将您的应用符号链接到该文件.
Then on your production server, create the very same file and symlink your app to it every time you deploy.
编辑.
Capistrano 几乎可以满足这些需求:
Capistrano is almost made to fits these needs:
把你的
yml
文件放在shared
文件夹
在您的 capistrano deploy.rb
文件中:
In your capistrano deploy.rb
file:
after 'deploy' do
run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml"
end
使用 yml 文件:http://railscasts.com/episodes/85-yaml-configuration-file
这篇关于在 rails 应用程序中放置安全密码/密钥的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!