Forum: Ruby on Rails HTTP Basic Authentication

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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
http://railscasts.com/episodes/82-http-basic-authentication

I'm trying to understand the document.
http://github.com/rails/rails/blob/be7b64b35aac1c9...

The RailsCasts sample is:

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

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"?

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

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

Dmitry
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.

Thanks.

John

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.