BasicAuthCredentials

BasicAuthCredentials is a very simple, small object that turns an HTTP basic auth header into a user ID and a password.

# these two lines create the same string that an HTTP client (such
# as a web browser) would send in the Authorization header.
encoded_credentials = Base64.encode64('my_username:my_password')
http_header_value = "Basic #{encoded_credentials}"

# And this is how you would decode that header value. Pretty simple.
credentials = BasicAuthCredentials.new(http_header_value)
credentials.user_id
#=> 'my_username'
credentials.password
#=> 'my_password'

Contributing to BasicAuthCredentials

Copyright © 2012 John Wilger. See LICENSE.txt for further details.