Forum: Ruby on Rails HTTP Basic Authentication

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Hunt J. (Guest)
on 2009-04-22 17:48
(Received via mailing list)
I'm trying to HTTP Basic Authentication mentioned at

I'm trying to understand the document.

The RailsCasts sample is:

def authenticate
  authenticate_or_request_with_http_basic do |username, password|
    username == "foo" && password == "bar"

But I would like to change "realm" as well. It looks possible in the
documentation. But I don't understand how to do it because my
understanding of block in Ruby isn't good.

Can anybody give me a sample that uses "realm"?

Dmitry S. (Guest)
on 2009-04-22 17:50
(Received via mailing list)

 authenticate_or_request_with_http_basic('YourRealm') do |username,
   username == "foo" && password == "bar"

Hunt J. (Guest)
on 2009-04-22 17:51
(Received via mailing list)
Thanks. That's how I can pass the first argument. Now I understand.



On Wed, Apr 22, 2009 at 10:49 PM, Dmitry S.
victor A. (Guest)
on 2012-05-21 18:01
Does the code.....

http_basic_authenticate_with :name=>"foo" :password=>"bar"

will this work?
This topic is locked and can not be replied to.