Skip to content

Commit

Permalink
Base64.strict_encode64 is not available on Ruby 1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jul 9, 2014
1 parent bba6d4b commit 8799f12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end

require 'yardstick/rake/verify'
Yardstick::Rake::Verify.new do |verify|
verify.threshold = 58.9
verify.threshold = 58.8
end

task :default => [:spec, :rubocop, :verify_measurements]
11 changes: 8 additions & 3 deletions lib/oauth2/mac_token.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'base64'
require 'securerandom'
require 'openssl'
require 'digest'
require 'openssl'
require 'securerandom'

module OAuth2
class MACToken < AccessToken
Expand Down Expand Up @@ -92,7 +92,7 @@ def signature(timestamp, nonce, verb, uri)
'', nil
].join("\n")

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

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

# Base64.strict_encode64 is not available on Ruby 1.8.7
def strict_encode64(str)
Base64.encode64(str).gsub("\n", '')
end
end
end

1 comment on commit 8799f12

@steved
Copy link
Contributor

@steved steved commented on 8799f12 Jul 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.