What is the difference between
http_basic_authenticate_with()
and
authenticate_or_request_with_http_basic()
methods?
Thanks for your full explanation.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With