Forum: Ruby on Rails Basic Auth in WEBrick

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.
4afd33d6e06fdf951d479a6699322cda?d=identicon&s=25 Eric Woodward (Guest)
on 2006-03-25 00:12
(Received via mailing list)
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 Woodward
Email: ejw@statewood.com
31ae911dd0fe0ee0b81519d6d2627886?d=identicon&s=25 Gravy Face (gravyface)
on 2006-03-25 00:21
(Received via mailing list)
On 3/24/06, Eric Woodward <ejw@statewood.com> 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
4afd33d6e06fdf951d479a6699322cda?d=identicon&s=25 Eric Woodward (Guest)
on 2006-03-25 04:56
(Received via mailing list)
Or maybe this:
http://wiki.rubyonrails.org/rails/pages/HowtoAuthe...

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 Woodward
Email: ejw@statewood.com
This topic is locked and can not be replied to.