From 6ce85f63bba4c9482b250e907d585c9fa88b1f7f Mon Sep 17 00:00:00 2001 From: Miguel Landaeta Date: Mon, 22 Jun 2015 20:58:40 -0300 Subject: [PATCH] Add support in Fog::AWS.signed_params_v4 to sign requests with query params and body --- lib/fog/aws.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/fog/aws.rb b/lib/fog/aws.rb index dfa8f2e45..e85476fbf 100644 --- a/lib/fog/aws.rb +++ b/lib/fog/aws.rb @@ -148,16 +148,21 @@ module Fog headers = headers.merge('Host' => options[:host], 'x-amz-date' => date.to_iso8601_basic) headers['x-amz-security-token'] = options[:aws_session_token] if options[:aws_session_token] + query = options[:query] || {} - body = '' - for key in params.keys.sort - unless (value = params[key]).nil? - body << "#{key}=#{escape(value.to_s)}&" + if !options[:body] + body = '' + for key in params.keys.sort + unless (value = params[key]).nil? + body << "#{key}=#{escape(value.to_s)}&" + end end + body.chop! + else + body = options[:body] end - body.chop! - headers['Authorization'] = options[:signer].sign({:method => options[:method], :headers => headers, :body => body, :query => {}, :path => options[:path]}, date) + headers['Authorization'] = options[:signer].sign({:method => options[:method], :headers => headers, :body => body, :query => query, :path => options[:path]}, date) return body, headers end