Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to use Rack::Auth::Digest::MD5
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Iñaki Baz Castillo  
View profile  
 More options Oct 16 2009, 2:33 pm
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Fri, 16 Oct 2009 20:33:57 +0200
Local: Fri, Oct 16 2009 2:33 pm
Subject: How to use Rack::Auth::Digest::MD5
Hi, could I get an example of Rack::Auth::Digest::MD5 usage? By reading the
doc I get confussed:

  http://rack.rubyforge.org/doc/Rack/Auth/Digest/MD5.html

The only I've found until now is a similar question with no response:

  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/313893

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iñaki Baz Castillo  
View profile  
 More options Oct 18 2009, 4:32 pm
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Sun, 18 Oct 2009 22:32:32 +0200
Local: Sun, Oct 18 2009 4:32 pm
Subject: Re: How to use Rack::Auth::Digest::MD5
El Viernes, 16 de Octubre de 2009, Iñaki Baz Castillo escribió:

> Hi, could I get an example of Rack::Auth::Digest::MD5 usage? By reading the
> doc I get confussed:

>   http://rack.rubyforge.org/doc/Rack/Auth/Digest/MD5.html

> The only I've found until now is a similar question with no response:

>   http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/313893

Any help please? I don't get it working and I don't know exactly what to try
since there is no documentation or examples.

Thanks.

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Magnus Holm  
View profile  
 More options Oct 19 2009, 7:33 am
From: Magnus Holm <judo...@gmail.com>
Date: Mon, 19 Oct 2009 13:33:27 +0200
Local: Mon, Oct 19 2009 7:33 am
Subject: Re: How to use Rack::Auth::Digest::MD5
What about something like this?

app = lambda do |env|
  [200, { 'Content-Type' => "text/html" }, ['Logged in!']]
end

app = Rack::Digest::MD5.new(app) do |username, password|
  username == "foo" && password == "bar"
end

run app

//Magnus Holm

On Sun, Oct 18, 2009 at 22:32, Iñaki Baz Castillo <i...@aliax.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iñaki Baz Castillo  
View profile  
 More options Oct 19 2009, 7:54 am
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Mon, 19 Oct 2009 13:54:00 +0200
Subject: Re: How to use Rack::Auth::Digest::MD5
El Lunes, 19 de Octubre de 2009, Magnus Holm escribió:

> What about something like this?

> app = lambda do |env|
>   [200, { 'Content-Type' => "text/html" }, ['Logged in!']]
> end

> app = Rack::Digest::MD5.new(app) do |username, password|
>   username == "foo" && password == "bar"
> end

> run app

Thanks, but what about if I just want to ask for authentication depending on
the URL?
For example:

I require authentication if the URL is:
  http://domain.org/service1/users/al...@domain.org/index.xml

But I don't require authentication if the URL is:
  http://domain.org/service1/global/index.xml

Also, there are cases in which I require Digest authentication if method is
PUT but not for GET.

Is it possible?

Thanks a lot.

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iñaki Baz Castillo  
View profile  
 More options Oct 19 2009, 8:07 am
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Mon, 19 Oct 2009 14:07:02 +0200
Local: Mon, Oct 19 2009 8:07 am
Subject: Re: How to use Rack::Auth::Digest::MD5
El Lunes, 19 de Octubre de 2009, Iñaki Baz Castillo escribió:

Also, I don't know which user, password and *realm* I must use to generate the
401 until I inspect the request. This is, in my previous example:
  http://domain.org/service1/users/al...@domain.org/index.xml

The 401 should contain a "WWW-Authenticate" header with fields:
- realm = domain.org
- username = alice

An the password (hassed ha1) would be retrieved from a DB.

Is it possible?

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Genta IHA  
View profile  
 More options Dec 18 2009, 9:52 am
From: Genta IHA <i...@inetcore.com>
Date: Fri, 18 Dec 2009 06:52:35 -0800 (PST)
Local: Fri, Dec 18 2009 9:52 am
Subject: Re: How to use Rack::Auth::Digest::MD5
Hello,

> Hi, could I get an example of Rack::Auth::Digest::MD5 usage? By reading the
> doc I get confussed:
 : (snip)
> Thanks, but what about if I just want to ask for authentication depending
>  on the URL?

Please try this example:

----
class DigestAuthApp
  USERS = {
    'office' => {
      'alice' => 'opensesame',
    },
    'home' => {
      'bob' => 'hello',
    },
  }

  def call(env)
    req = Rack::Request.new(env)
    return view_global(env) if %r!^/service1/global/! =~ req.fullpath
    _, user, realm, path = *%r!^/service1/users/(\w+)@([^/]+)/
(.*)!.match(req.fullpath)

    # authentication needed for users area
    env = callcc do |cont|
      auth = Rack::Auth::Digest::MD5.new(cont, realm) {|u| USERS[realm]
[user] }
      auth.opaque = $$.to_s  # or your favorite opaque
      return auth.call(env)  # => returns 401 if not authenticated
    end
    # authenticated
    req = Rack::Request.new(env)
    auth_user = req.env['REMOTE_USER']

    body = ''
    [['user', auth_user], ['realm', realm], ['path', path]].each do |
k, v|
      body += k + ': ' + v + "\n"
    end
    [200, {"Content-Type" => "text/plain"}, body]
  end

  def view_global(env)
    [200, {"Content-Type" => "text/plain"}, 'Welcome to global area.
Enjoy!']
  end
end
----

for /service1/users/.*@office/something:
  alice is permitted. bob is not.

for /service1/users/.*@home/something:
  bob is permitted. alice is not.

for /service1/global/something:
  Everyone is permitted.

--
Genta IHA
i...@inetcore.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iñaki Baz Castillo  
View profile  
 More options Dec 18 2009, 1:09 pm
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Fri, 18 Dec 2009 19:09:44 +0100
Local: Fri, Dec 18 2009 1:09 pm
Subject: Re: How to use Rack::Auth::Digest::MD5
El Viernes, 18 de Diciembre de 2009, Genta IHA escribió:

Great! thanksa lot, I'll try it.

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iñaki Baz Castillo  
View profile  
 More options Dec 18 2009, 1:41 pm
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Fri, 18 Dec 2009 19:41:47 +0100
Local: Fri, Dec 18 2009 1:41 pm
Subject: Re: How to use Rack::Auth::Digest::MD5
El Viernes, 18 de Diciembre de 2009, Genta IHA escribió:

>     # authentication needed for users area
>     env = callcc do |cont|
>       auth = Rack::Auth::Digest::MD5.new(cont, realm) {|u| USERS[realm]
> [user] }

I get an error: what is "callcc"?

Thanks a lot.

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iñaki Baz Castillo  
View profile  
 More options Dec 18 2009, 2:19 pm
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Fri, 18 Dec 2009 20:19:29 +0100
Local: Fri, Dec 18 2009 2:19 pm
Subject: Re: How to use Rack::Auth::Digest::MD5
El Viernes, 18 de Diciembre de 2009, Iñaki Baz Castillo escribió:

> El Viernes, 18 de Diciembre de 2009, Genta IHA escribió:
> >     # authentication needed for users area
> >     env = callcc do |cont|
> >       auth = Rack::Auth::Digest::MD5.new(cont, realm) {|u| USERS[realm]
> > [user] }

> I get an error: what is "callcc"?

Ops, 'callcc' exists in Ruby1.8, but not in 1.9 !

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iñaki Baz Castillo  
View profile  
 More options Dec 18 2009, 2:21 pm
From: Iñaki Baz Castillo <i...@aliax.net>
Date: Fri, 18 Dec 2009 20:21:00 +0100
Subject: Re: How to use Rack::Auth::Digest::MD5
El Viernes, 18 de Diciembre de 2009, Iñaki Baz Castillo escribió:

> El Viernes, 18 de Diciembre de 2009, Iñaki Baz Castillo escribió:
> > El Viernes, 18 de Diciembre de 2009, Genta IHA escribió:
> > >     # authentication needed for users area
> > >     env = callcc do |cont|
> > >       auth = Rack::Auth::Digest::MD5.new(cont, realm) {|u| USERS[realm]
> > > [user] }

> > I get an error: what is "callcc"?

> Ops, 'callcc' exists in Ruby1.8, but not in 1.9 !

Sorry, it does exist, but "continuation" library must be loaded (while in 1.8
it seems to be loaded always).

--
Iñaki Baz Castillo <i...@aliax.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »