是什么区别
http_basic_authenticate_with()
和
authenticate_or_request_with_http_basic()
方法?
感谢您的完整的解释。
从我可以从docs了解,http_basic_authenticate_with
作为它接受一个名称和密码,如前过滤器
http_basic_authenticate_with :name => "dhh", :password => "secret", :except => :index
而authenticate_or_request_with_http_basic接受块允许你插入一些代码,以确定他们是否应该被验证(documentation)。例如。
before_filter :authenticate
def authenticate
authenticate_or_request_with_http_basic('Administration') do |username, password|
ActiveSupport::SecurityUtils.secure_compare(username, "admin") &&
ActiveSupport::SecurityUtils.secure_compare(password, "password")
end
end