mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Merge pull request #133 from fcheung/fix_s3_signer
Fix S3 signature v4 signing
This commit is contained in:
commit
ae2b2d7210
2 changed files with 21 additions and 12 deletions
|
@ -79,6 +79,7 @@ DATA
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def canonical_path(path)
|
def canonical_path(path)
|
||||||
|
unless @service == 's3' #S3 implements signature v4 different - paths are not canonialized
|
||||||
#leading and trailing repeated slashes are collapsed, but not ones that appear elsewhere
|
#leading and trailing repeated slashes are collapsed, but not ones that appear elsewhere
|
||||||
path = path.gsub(%r{\A/+},'/').gsub(%r{/+\z},'/')
|
path = path.gsub(%r{\A/+},'/').gsub(%r{/+\z},'/')
|
||||||
components = path.split('/',-1)
|
components = path.split('/',-1)
|
||||||
|
@ -91,6 +92,7 @@ DATA
|
||||||
end
|
end
|
||||||
acc
|
acc
|
||||||
end.join('/')
|
end.join('/')
|
||||||
|
end
|
||||||
path.empty? ? '/' : path
|
path.empty? ? '/' : path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -96,5 +96,12 @@ Shindo.tests('AWS | signaturev4', ['aws']) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("s3 signer does not normalize path") do
|
||||||
|
signer=Fog::AWS::SignatureV4.new('AKIDEXAMPLE', 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY', 'us-east-1','s3')
|
||||||
|
returns(signer.sign({:query => {}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '//foo/../bar/./'}, @now)) do
|
||||||
|
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/s3/aws4_request, SignedHeaders=date;host, Signature=72407ad06b8e5750360f42e8aad9f33a0be363bcfeecdcae0aea58c99709fb4a'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Fog::Time.now = ::Time.now
|
Fog::Time.now = ::Time.now
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue