lib/oauthenticator/signable_request.rb in oauthenticator-1.2.0 vs lib/oauthenticator/signable_request.rb in oauthenticator-1.3.0

- old
+ new

@@ -67,14 +67,14 @@ # validation - presence required = %w(request_method uri media_type body) required += %w(signature_method consumer_key) unless @attributes['authorization'] missing = required - @attributes.keys - raise ArgumentError, "missing: #{missing.inspect}" if missing.any? + raise ArgumentError, "missing required attributes: #{missing.inspect}" if missing.any? other_recognized = PROTOCOL_PARAM_KEYS + %w(authorization consumer_secret token_secret realm hash_body?) extra = @attributes.keys - (required + other_recognized) - raise ArgumentError, "received unrecognized @attributes: #{extra.inspect}" if extra.any? + raise ArgumentError, "received unrecognized attributes: #{extra.inspect}" if extra.any? if @attributes['authorization'] # this means we are signing an existing request to validate the received signature. don't use defaults. unless @attributes['authorization'].is_a?(Hash) raise TypeError, "authorization must be a Hash" @@ -295,20 +295,20 @@ # signature, with method RSA-SHA1. section 3.4.3 # # @return [String] def rsa_sha1_signature private_key = OpenSSL::PKey::RSA.new(@attributes['consumer_secret']) - Base64.encode64(private_key.sign(OpenSSL::Digest::SHA1.new, signature_base)).chomp.gsub(/\n/, '') + Base64.encode64(private_key.sign(OpenSSL::Digest::SHA1.new, signature_base)).gsub(/\n/, '') end # signature, with method HMAC-SHA1. section 3.4.2 # # @return [String] def hmac_sha1_signature # hmac secret is same as plaintext signature secret = plaintext_signature - Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, secret, signature_base)).chomp.gsub(/\n/, '') + Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, secret, signature_base)).gsub(/\n/, '') end # signature, with method plaintext. section 3.4.4 # # @return [String] @@ -318,10 +318,10 @@ # body hash, with a signature method which uses SHA1. oauth request body hash section 3.2 # # @return [String] def sha1_body_hash - Base64.encode64(OpenSSL::Digest::SHA1.digest(read_body)).chomp.gsub(/\n/, '') + Base64.encode64(OpenSSL::Digest::SHA1.digest(read_body)).gsub(/\n/, '') end # map of oauth signature methods to their signature instance methods on this class SIGNATURE_METHODS = { 'RSA-SHA1'.freeze => instance_method(:rsa_sha1_signature),