Basic Auth in WEBrick

Yo all,

All I want to accomplish at this moment in time is simple password
protection around a rails application in development using WEBrick on
a custom port. Just one account would be fine.

I have done an extensive Google hunt for an example, but I all find
are code chunks for starting WEBrick such as:

  realm = "Gnome realm"
  start_webrick {|server|
    htpasswd = HTTPAuth::Htpasswd.new(/tmp/gnome.htpasswd)
    authenticator = HTTPAuth::BasicAuth.new(
      :UserDb => htpasswd
      :Realm => realm
     )
     server.mount_proc(/htpasswd_auth) {|req resp|
     authenticator.authenticate(req resp)
     resp.body = "You are authenticated to see the super secret

datan"
}
}

Do I replace the script/server file with something like this? If
there an actual example of working with rails, not just WEBrick as a
standalone server, someone can point me to?

–ejw

Eric W.
Email: [email protected]

On 3/24/06, Eric W. [email protected] wrote:

All I want to accomplish at this moment in time is simple password
protection around a rails application in development using WEBrick on
a custom port. Just one account would be fine.

You should check out this:

http://wiki.rubyonrails.com/rails/pages/LoginGenerator

Or maybe this:
http://wiki.rubyonrails.org/rails/pages/HowtoAuthenticateWithHTTP

The point was that I do not want to deal with all of this for the
simple thing of preventing anyone from looking at our development
versions, like I could do in 5 seconds with .htaccess in Apache. We
already have login and password access to management areas, and like
WEBrick and want to continue using it for development.

Is there really no way to hook in basic HTTP authentication
completely separate from the application itself for rails out of
the box?

–ejw

Eric W.
Email: [email protected]