# Basic authentication with WEBrick?

**URL:** <https://www.ruby-forum.com/t/basic-authentication-with-webrick/67772>\
**Category:** Ruby\
**Created:** [September 6, 2006, 6:40pm UTC](https://www.ruby-forum.com/t/basic-authentication-with-webrick/67772 "2006-09-06T18:40:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasudevram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/bbce88/32.png) [@vasudevram](https://www.ruby-forum.com/u/vasudevram)\
**Post date:** [September 6, 2006, 6:40pm UTC](https://www.ruby-forum.com/t/basic-authentication-with-webrick/67772/1 "2006-09-06T18:40:31Z")

</div>

Hi,

We are using WEBrick on port 80 for development of a Rails app. [We may  
move to Mongrel or some other option later].

Assume our host is [http://my.host.com](http://my.host.com).

When we go to [http://my.host.com](http://my.host.com), we get our Rails app’s first page  
shown correctly.  
At this page we will have a login form with username and password.

But we also want to have one more level of authentication, before this  
form is shown, a Web server authentication, i.e. when a user tries to  
access the URL [http://my.host.com](http://my.host.com), a login dialog should be shown  
asking for a username and password - not the username and password of  
the Rails app, but one that is handled by the WEBrick server - as I  
think is possible (not sure) if using Apache as the web server. Is  
there a way to do this with WEBrick?

Thanks  
Vasudev

> **[dancingbison.com](http://ww38.dancingbison.com/)**
>
> Learn Python Programming

---

<div class="post-metadata">

**Author:** ![vasudevram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/bbce88/32.png) [@vasudevram](https://www.ruby-forum.com/u/vasudevram)\
**Post date:** [September 7, 2006, 8:41am UTC](https://www.ruby-forum.com/t/basic-authentication-with-webrick/67772/2 "2006-09-07T08:41:57Z")

</div>

vasudevram wrote:

> But we also want to have one more level of authentication, before this  
> form is shown, a Web server authentication, i.e. when a user tries to  
> access the URL [http://my.host.com](http://my.host.com), a login dialog should be shown  
> asking for a username and password - not the username and password of  
> the Rails app, but one that is handled by the WEBrick server - as I  
> think is possible (not sure) if using Apache as the web server. Is  
> there a way to do this with WEBrick?

Sure, you can just send http basic or digest authentication headers  
from Rails or if you hack around a little bit, WEBrick. I just released  
a library for http authentication last week, the digest stuff is still  
beta, but you can use the basic authentication.

[http://httpauth.rubyforge.org/classes/HTTPAuth/Basic.html](http://httpauth.rubyforge.org/classes/HTTPAuth/Basic.html)

The rubyforge project page is here:

[http://rubyforge.org/projects/httpauth/](http://rubyforge.org/projects/httpauth/)

---

<div class="post-metadata">

**Author:** ![vasudevram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/bbce88/32.png) [@vasudevram](https://www.ruby-forum.com/u/vasudevram)\
**Post date:** [September 7, 2006, 8:05pm UTC](https://www.ruby-forum.com/t/basic-authentication-with-webrick/67772/3 "2006-09-07T20:05:42Z")

</div>

On Sep 6, 2006, at 9:40 AM, vasudevram wrote:

> But we also want to have one more level of authentication, before this  
> form is shown, a Web server authentication, i.e. when a user tries to  
> access the URL [http://my.host.com](http://my.host.com), a login dialog should be shown  
> asking for a username and password - not the username and password of  
> the Rails app, but one that is handled by the WEBrick server - as I  
> think is possible (not sure) if using Apache as the web server. Is  
> there a way to do this with WEBrick?

[http://microjet.ath.cx/webrickguide/html/HTTP\_Authentication.html](http://microjet.ath.cx/webrickguide/html/HTTP_Authentication.html)

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![vasudevram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/bbce88/32.png) [@vasudevram](https://www.ruby-forum.com/u/vasudevram)\
**Post date:** [September 10, 2006, 6:37pm UTC](https://www.ruby-forum.com/t/basic-authentication-with-webrick/67772/4 "2006-09-10T18:37:06Z")

</div>

Eric H. wrote:

> > At this page we will have a login form with username and password.
> 
> [http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

Thanks, all. Will check the links given.

Vasudev

> **[dancingbison.com](http://ww38.dancingbison.com/)**
>
> Learn Python Programming
