Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/oauth2/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def apply(params)
end

def self.encode_basic_auth(user, password)
'Basic ' + Base64.encode64(user + ':' + password).delete("\n")
'Basic ' + Base64.strict_encode64(user + ':' + password)
end

private
Expand Down
7 changes: 1 addition & 6 deletions lib/oauth2/mac_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def signature(timestamp, nonce, verb, uri)
'', nil
].join("\n")

strict_encode64(OpenSSL::HMAC.digest(@algorithm, secret, signature))
Base64.strict_encode64(OpenSSL::HMAC.digest(@algorithm, secret, signature))
end

# Set the HMAC algorithm
Expand All @@ -113,10 +113,5 @@ def algorithm=(alg)
# and the MAC always goes in a header
def token=(_noop)
end

# Base64.strict_encode64 is not available on Ruby 1.8.7
def strict_encode64(str)
Base64.encode64(str).delete("\n")
end
end
end
2 changes: 1 addition & 1 deletion spec/oauth2/authenticator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

context 'with Basic authentication' do
let(:mode) { :basic_auth }
let(:header) { 'Basic ' + Base64.encode64("#{client_id}:#{client_secret}").delete("\n") }
let(:header) { 'Basic ' + Base64.strict_encode64("#{client_id}:#{client_secret}") }

it 'encodes credentials in headers' do
output = subject.apply({})
Expand Down