Created
May 20, 2010 14:18
-
-
Save tjh/407605 to your computer and use it in GitHub Desktop.
This file contains 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
# This method allows the app to figure out what username and password were passed | |
# via basic http auth. Because calling #authenticate_or_request_with_http_basic will | |
# fail if no password was sent, I had to hack in my own check (taken from the Rails | |
# source) to make sure that they tried to auth. | |
def get_credentials | |
log_it | |
# Grabbed from the rails source...if the user sent auth data... | |
if ( request.env['HTTP_AUTHORIZATION'] || | |
request.env['X-HTTP_AUTHORIZATION'] || | |
request.env['X_HTTP_AUTHORIZATION'] || | |
request.env['REDIRECT_X_HTTP_AUTHORIZATION'] | |
) then | |
authenticate_or_request_with_http_basic do |username, password| | |
@username = username | |
@password = password | |
end | |
end | |
true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment