Created
January 29, 2012 00:29
-
-
Save chumpy/1696418 to your computer and use it in GitHub Desktop.
Basic Auth w/Restful Authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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