从 github 隐藏我的敏感信息(例如密码)我的、敏感、密码、信息

2023-09-07 09:31:18 作者:疲惫的不是脚步而是心情

我刚刚设置了 Devise(rails 身份验证插件)以在注册时发送确认电子邮件.这涉及到我将以下内容放入我的 environment.rb 文件中:

I just set up Devise (rails authentication plugin) to send a confirmation email upon sign up. This involved my putting the following into my environment.rb file:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
   :tls => true,
   :address => "smtp.gmail.com",
   :port => 587,
   :domain => "gmail.com",
   :authentication => :login,
   :user_name => "[my email]",
   :password => "[my pass]"
 }

我显然不想在 [my pass] 坐在那里的情况下将其推送到 github.这里有标准做法吗?

I obviously don't want to push this up to github with [my pass] just sitting there. Is there a standard practice here?

推荐答案

标准是将您的配置设置放在一个 YAML 文件中,该文件不包含在您的存储库中.

The standard is to put your configuration settings in one YAML file which isn't included in your repo.

然后您只需从中获取数据.

Then you simply get the data from it.

检查 Railscast "#85 YAML 配置文件" 以查看它的实际效果.

Check Railscast "#85 YAML Configuration File" to see it in action.