How to set up HTTP authentication in a Rails application running on WEBrick?
Rails has a built in method for adding http basic authentication.
You should also look at something like Authlogic for authentication and user session management.