mirror of
https://github.com/lostisland/faraday.git
synced 2025-08-30 00:03:09 -04:00
Strip out extra new lines from basic auth headers
This commit is contained in:
parent
53d4244e97
commit
7ff6f56701
@ -81,7 +81,9 @@ module Faraday
|
||||
end
|
||||
|
||||
def basic_auth(login, pass)
|
||||
@headers['authorization'] = "Basic #{Base64.encode64("#{login}:#{pass}").strip}"
|
||||
auth = Base64.encode64("#{login}:#{pass}")
|
||||
auth.gsub!("\n", "")
|
||||
@headers['authorization'] = "Basic #{auth}"
|
||||
end
|
||||
|
||||
def token_auth(token, options = {})
|
||||
|
@ -58,6 +58,12 @@ class TestConnection < Faraday::TestCase
|
||||
assert_equal 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==', conn.headers['Authorization']
|
||||
end
|
||||
|
||||
def test_long_basic_auth_sets_authorization_header_without_new_lines
|
||||
conn = Faraday::Connection.new
|
||||
conn.basic_auth "A" * 255, ""
|
||||
assert_equal "Basic #{'QUFB' * 85}Og==", conn.headers['Authorization']
|
||||
end
|
||||
|
||||
def test_auto_parses_basic_auth_from_url
|
||||
conn = Faraday::Connection.new :url => "http://aladdin:opensesame@sushi.com/fish"
|
||||
assert_equal 'Basic YWxhZGRpbjpvcGVuc2VzYW1l', conn.headers['Authorization']
|
||||
|
Loading…
x
Reference in New Issue
Block a user