4

Rails 3仍支持HTTP摘要認證嗎?Rails 3 HTTP摘要認證

我在Rails 2.3.5中試過下面的代碼,它工作。

class Admin::BaseController < ApplicationController 
    before_filter :authenticate 
    USERS = { "lifo" => "world" } 
    def authenticate 
    authenticate_or_request_with_http_digest("Application") do |name| 
     USERS[name] 
    end 
    end 
end 

現在,在Rails的同樣的事情3.0.0.beta返回一個錯誤:

can't convert nil into String 

我缺少的東西,或這是Rails 3中的錯誤嗎? HTTP基本身份驗證正常工作。

回答

1

Rails beta2中的同樣的問題。

一個快速和骯髒的解決辦法:

添加

self.config.secret = "result of rake secret" 

authenticate_or_request_with_http_digest("Application")