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")