开发者

Rails 3 HTTP digest authentication

开发者 https://www.devze.com 2022-12-26 13:41 出处:网络
Is HTTP digest开发者_如何学Python authentication still supported in Rails 3? I tried the following code in Rails 2.3.5, it works.

Is HTTP digest开发者_如何学Python authentication still supported in Rails 3?

I tried the following code in Rails 2.3.5, it works.

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

Now, the same thing in Rails 3.0.0.beta returns an error:

can't convert nil into String

Am I missing something or is this a bug in Rails 3? HTTP basic authentication works fine.


Same problem in Rails beta2.

A quick and dirty fix:

add

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

before

authenticate_or_request_with_http_digest("Application")
0

精彩评论

暂无评论...
验证码 换一张
取 消