How Do You Secure database.yml?

前端 未结 6 764
自闭症患者
自闭症患者 2021-01-30 10:26

Within Ruby on Rails applications database.yml is a plain text file that stores database credentials.

When I deploy my Rails applications I have an after deploy callback

6条回答
  •  情书的邮戳
    2021-01-30 11:16

    The way I have tackled this is to put the database password in a file with read permissions only for the user I run my application as. Then, in database.yml I use ERB to read the file:

    production:
      adapter: mysql
      database: my_db
      username: db_user
      password: <%= begin IO.read("/home/my_deploy_user/.db") rescue "" end %>
    

    Works a treat.

提交回复
热议问题