# Digest Authentication in Rack

**URL:** <https://www.ruby-forum.com/t/digest-authentication-in-rack/147758>\
**Category:** Ruby\
**Created:** [September 5, 2008, 4:38am UTC](https://www.ruby-forum.com/t/digest-authentication-in-rack/147758 "2008-09-05T04:38:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roxah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/54ee81/32.png) [@roxah](https://www.ruby-forum.com/u/roxah)\
**Post date:** [September 5, 2008, 4:38am UTC](https://www.ruby-forum.com/t/digest-authentication-in-rack/147758/1 "2008-09-05T04:38:42Z")

</div>

Hello all,

Has anyone been able to figure out how to use the digest authentication  
provided in Rack? I tried searching the web and tried reading Rack’s  
documentation, but still haven’t had any success. The  
Rack::Auth::Digest::MD5 class has the following documentation:

# Rack::Auth::Digest::MD5 implements the MD5 algorithm version of

# HTTP Digest Authentication, as per RFC 2617.

# 

# Initialize with the [Rack] application that you want protecting,

# and a block that looks up a plaintext password for a given username.

# 

# +opaque+ needs to be set to a constant base64/hexadecimal string.

So, I tried the following:

require ‘rubygems’  
require ‘sinatra’

get ‘/admin’ do  
Rack::Auth::Digest::MD5.new(self) do |u,p|  
u == ‘foo’ && p == ‘bar’  
end  
“Authorized!”  
end

However, I was never asked for my credentials…

So, has anyone had the chance to get this working?

–  
Thanks!  
Bryan
