What is the difference between
http_basic_authenticate_with()
and
authenticate_or_request_with_http_basic()
From what I can understand from the docs, http_basic_authenticate_with
acts as a before filter which accepts a name and password such as
http_basic_authenticate_with :name => "dhh", :password => "secret", :except => :index
Whereas authenticate_or_request_with_http_basic accepts a block allowing for you to insert some code to determine whether they should be authenticated (documentation). E.g.
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