views:

66

answers:

3

I am in the process of hosting my first rails app and I would like to not open it up to the public until I am done with all production work, which might take a few weeks, but I would like to expose it to friends/beta testers. I use authlogic for authentication but I don't even want anybody to go that point, I would like to set up some form authentication (http basic?) that only certian people can login with and once they do, the site works as usual. Basically I just want this new layer of login to not mess the application, something that I can just slap on and remove once the prod testing is done.

1 - Does authlogic http authentication work for this purpose? Anythnig else?

A: 

Don't know how you're hosting it, or how high security it is, but why not just limit the source IP addresses, or the Mac Addresses, that can access it via your webserver?

jasonpgignac
A: 

Yes it does support http basic, you just need to configure it in your User model. Or you can setup a demo account and give that away to your friends.

jpartogi
Thanks, whats teh difference between teh native rails authentication and authlogic's http authentication. does it do some sort of session maintenane? Forgive my ignorance, but let's say I use the basic rails http auth as a before filter in my app_controler, will every page load ask for http auth or is the session gonna stay active until the browser is closed?
badnaam
+4  A: 

Your application controller can handle HTTP Basic Authentication -- you keep authlogic for all your public/private stuff, and just let Rails handle authentication.

/app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery
  layout 'application'

  USER_ID, PASSWORD = "yourusername", "yourpassword"

  before_filter :authenticate

  private
  def authenticate
    authenticate_or_request_with_http_basic do |id, password| 
      id == USER_ID && password == PASSWORD
    end
  end
end
Jesse Wolgamott