Rails http_basic_authenticate_with

use*_*710 3 authentication passwords ruby-on-rails

刚刚有一个关于 http_basic_authenticate_with 的新手问题。如果我在我的控制器中放置一些简单的东西,

http_basic_authenticate_with :name => "user", :password => "secret"
Run Code Online (Sandbox Code Playgroud)

我怎样才能确保密码是安全的。我只是希望能够将应用程序投入生产/发布,并以安全的方式保护整个应用程序密码。

感谢您的任何建议。

小智 5

我可以建议将密码放在环境中。例如你可以做http://www.cyberciti.biz/faq/set-environment-variable-linux/ export APP_USER='secret_user' export APP_PASSWORD='secret_password'

# then in controller
http_basic_authenticate_with :name => ENV['secret_user'], :password => ENV['secret_password']
Run Code Online (Sandbox Code Playgroud)