Skip to content

Instantly share code, notes, and snippets.

@chumpy
Created January 29, 2012 00:29
Show Gist options
  • Select an option

  • Save chumpy/1696418 to your computer and use it in GitHub Desktop.

Select an option

Save chumpy/1696418 to your computer and use it in GitHub Desktop.
Basic Auth w/Restful Authentication
# Here’s a way to do http basic authentication and tie it in
# to the Restful Authentication mechanism to make current_person accessible:
def authenticate_person
authenticate_or_request_with_http_basic do |login, password|
person = Person.authenticate(login, password)
return false if !person or person.nil?
session[:person_id] = person.id
end
end
# then just add before_filter :authenticate_person to your controller.
# You can now access current_person to obtain the person that
# logged in via the basic auth.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment