Created
July 29, 2010 19:30
-
-
Save technoweenie/498995 to your computer and use it in GitHub Desktop.
less crappy implementation that fixed a bug if the base64 included whitespace in the middle
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
@@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization) | |
# gets BASIC auth info | |
def get_auth_data | |
auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) } | |
if auth_key.present? && request.env[auth_key].to_s =~ /^Basic\s+(.*)/m | |
Base64.decode64($1).split(':')[0..1] | |
else | |
[nil, nil] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment