我想要一個子域像... admin.example.comRuby on Rails:如何製作http密碼保護的子域?
但我希望它需要用戶和密碼。就像......使用瀏覽器界面的那種,而不是數據庫支持的認證系統。
這樣做有什麼好方法?
我想要一個子域像... admin.example.comRuby on Rails:如何製作http密碼保護的子域?
但我希望它需要用戶和密碼。就像......使用瀏覽器界面的那種,而不是數據庫支持的認證系統。
這樣做有什麼好方法?
這是相當簡單:
# 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
寫小架的應用。這兩個檢查是否正確的子域和強制執行基本身份驗證可以輕鬆完成。
本着railscasts的精神,這個http://railscasts.com/episodes/221-subdomains-in-rails-3會告訴你關於子域名的一切。 – 2010-11-29 15:15:41
涵蓋認證部分= \謝謝!現在只需要子域。 = \ – NullVoxPopuli 2010-11-29 15:14:19