mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Fix v4 signature when path has repeated slashes in the middle
This commit is contained in:
parent
00607d6363
commit
1b820466e5
2 changed files with 9 additions and 1 deletions
|
@ -79,7 +79,9 @@ DATA
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def canonical_path(path)
|
def canonical_path(path)
|
||||||
components = path.split(%r{/+}, -1)
|
#leading and trailing repeated slashes are collapsed, but not ones that appear elsewhere
|
||||||
|
path = path.gsub(%r{\A/+},'/').gsub(%r{/+\z},'/')
|
||||||
|
components = path.split('/',-1)
|
||||||
path = components.inject([]) do |acc, component|
|
path = components.inject([]) do |acc, component|
|
||||||
case component
|
case component
|
||||||
when '.' #canonicalize by removing .
|
when '.' #canonicalize by removing .
|
||||||
|
|
|
@ -62,6 +62,12 @@ Shindo.tests('AWS | signaturev4', ['aws']) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests('get with repeated // inside path') do
|
||||||
|
returns(@signer.sign({:query => {}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '/foo//bar//baz'}, @now)) do
|
||||||
|
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b250c85c72c5d7c33f67759c7a1ad79ea381cf62105290cecd530af2771575d4'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
tests('get with repeated trailing / ') do
|
tests('get with repeated trailing / ') do
|
||||||
returns(@signer.sign({:query => {}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '//foo//'}, @now)) do
|
returns(@signer.sign({:query => {}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '//foo//'}, @now)) do
|
||||||
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b00392262853cfe3201e47ccf945601079e9b8a7f51ee4c3d9ee4f187aa9bf19'
|
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b00392262853cfe3201e47ccf945601079e9b8a7f51ee4c3d9ee4f187aa9bf19'
|
||||||
|
|
Loading…
Reference in a new issue