有没有办法为heroku上的Ruby on Rails应用程序设置简单的http身份验证? [英] Is there a way to set up simple http authentication for a Ruby on Rails app on heroku?

查看:24
本文介绍了有没有办法为heroku上的Ruby on Rails应用程序设置简单的http身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用简单的 http 身份验证在 heroku 上设置一个私有临时服务器.这可能吗?

I want to set up a private staging server on heroku using simple http authentication. Is that possible?

推荐答案

绝对可以.最简单的解决方案是在使用 Rails 内置基本身份验证支持的应用程序控制器中放置一些东西(请参阅此处:http://railscasts.com/episodes/82-http-basic-authentication) 并将其包装在 Rails.env 的条件中.请注意,在 Heroku 上,默认情况下 RAILS_ENV 设置为生产,但您可以使用 heroku config (http://docs.heroku.com/config-vars).

Absolutely. The simplest solution is to just put something in your application controller that uses Rails's built in basic auth support (see here: http://railscasts.com/episodes/82-http-basic-authentication) and just wrap it in a conditional for your Rails.env. Note that on Heroku, by default the RAILS_ENV is set to production, but you can change this for your non-production apps using heroku config (http://docs.heroku.com/config-vars).

你也可以考虑安装一些路障式的 Rack 中间件,但我只会选择上面的.

You could also consider installing some roadblock-style Rack middleware, but I'd just go with the above.

这篇关于有没有办法为heroku上的Ruby on Rails应用程序设置简单的http身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆