4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/uber-s3/authorization.rb', line 4
def sign(client, verb, path, ={})
req_verb = verb.to_s.upcase
req_content_md5 = ['Content-MD5']
req_content_type = ['Content-Type']
req_date = ['Date']
req_canonical_resource = "/#{client.bucket}/#{path}".split('?').first
= ''
.keys.sort.select {|k| k =~ /^x-amz-/ }.each do |amz_key|
<< amz_key+':'+[amz_key]+"\n"
end
canonical_string_to_sign = "#{req_verb}\n"+
"#{req_content_md5}\n"+
"#{req_content_type}\n"+
"#{req_date}\n"+
"#{}"+
"#{req_canonical_resource}"
digest = OpenSSL::Digest::Digest.new('sha1')
[OpenSSL::HMAC.digest(digest, client.connection.secret_access_key, canonical_string_to_sign)].pack("m").strip
end
|