我想要一个像... admin.example.com
这样的子域名但我希望它需要用户和密码。就像......使用浏览器界面的那种,而不是数据库支持的身份验证系统。
这样做有什么好方法?
答案 0 :(得分:2)
这很简单:
# products_controller.rb
before_filter :authenticate
protected
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "foo" && password == "bar"
end
end
请参阅:http://railscasts.com/episodes/82-http-basic-authentication
答案 1 :(得分:1)
编写一个小型机架应用程序。检查其是否正确的子域并强制执行基本身份验证都可以轻松完成。