class HmacSignature::Signature

Constants

VERSION

Public Instance Methods

string_to_sign() click to toggle source
# File lib/hmac_signature/signature.rb, line 12
def string_to_sign
        [method, path, parameter_string].join("\n")
end
to_s() click to toggle source
# File lib/hmac_signature/signature.rb, line 7
def to_s
        digest = OpenSSL::Digest::SHA256.new
        OpenSSL::HMAC.hexdigest(digest, secret, string_to_sign)
end

Private Instance Methods

credential_hash() click to toggle source
# File lib/hmac_signature/signature.rb, line 18
def credential_hash
        { :auth_expiry => timestamp, :auth_version => version, :auth_key => key }
end
parameter_string() click to toggle source
# File lib/hmac_signature/signature.rb, line 22
def parameter_string
        hash = params.merge credential_hash

        # Convert keys to lowercase strings
        hash = hash.inject({}) do |memo, (k,v)|
                memo[k.to_s.downcase] = v
                memo
        end

        hash.sort.map do |k, v|
                QueryEncoder.encode_param_without_escaping(k, v)
        end.join('&')
end