我想解决什么是确保我的临时环境的最佳方式。目前,我正在同一台服务器上运行分段和生产。密码保护导轨临时环境
我能想到的两个选项将是:
使用轨道摘要式身份验证
我可以把这样的事情在application_controller.rb
# Password protection for staging environment
if RAILS_ENV == 'staging'
before_filter :authenticate_for_staging
end
def authenticate_for_staging
success = authenticate_or_request_with_http_digest("Staging") do |username|
if username == "staging"
"staging_password"
end
end
unless success
request_http_digest_authentication("Admin", "Authentication failed")
end
end
这被撕开从Ryan Daigle's blog。我正在运行最新的Rails 2.3,所以我应该从这个安全问题中解脱出来。
使用Web服务器身份验证
我也可以做到这一点使用的.htaccess或Apache许可,但它使我的服务器配置稍微复杂一些(我使用的是厨师,并需要分期不同阿帕奇CONFIGS /生产)。
现在我有第一个实施和工作,你看到它的问题吗?我错过了明显的东西吗?提前致谢!
还有最近添加的这个选项:https://github.com/rails/rails/commit/e2b07ee000439d0bd41f725ff9f7ad53e52a7e9b,我喜欢你的解决方案,但我认为这是一条路。 – jonnii 2011-04-06 15:02:30