【问题标题】:Rails 3 HTTP digest authenticationRails 3 HTTP 摘要认证
【发布时间】:2010-04-13 20:24:55
【问题描述】:

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

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 http-authentication digest-authentication


    【解决方案1】:

    Rails beta2 中的同样问题。

    快速而肮脏的修复:

    添加

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

    之前

    authenticate_or_request_with_http_digest("Application")
    

    【讨论】:

      猜你喜欢
      • 2020-09-17
      • 1970-01-01
      • 2017-06-26
      • 2011-05-03
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 2019-07-30
      相关资源
      最近更新 更多