Rails 3 HTTP 摘要身份验证

发布于 2024-08-28 22:55:45 字数 494 浏览 5 评论 0原文

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 基本身份验证工作正常。

Is HTTP digest 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞旧 2024-09-04 22:55:45

Rails beta2 中也存在同样的问题。

一个快速但肮脏的修复:

添加

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

之前

authenticate_or_request_with_http_digest("Application")

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")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文