Skip to content

Commit

Permalink
Bug fix for s3 presigned urls using secure: false.
Browse files Browse the repository at this point in the history
Closes #998
  • Loading branch information
trevorrowe committed Dec 9, 2015
1 parent 794a2cf commit 7a730b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Unreleased Changes
------------------

* Issue - Aws::S3 - Resolved a regression with `Aws::S3::Presigner#presigned_url`
when using the `secure: false` option. Added integration test to prevent
future regressions.

See [related GitHub issue #998](https://github.com/aws/aws-sdk-ruby/issues/998).

* Issue - Aws::Route53 - Fixed an issue that prevented users from calling the
`Aws::Route53::Client#get_traffic_policy` operation. The endpoint builder
was failing to convert the paramters to strings before URI encoding them.
Expand Down
9 changes: 8 additions & 1 deletion aws-sdk-core/features/s3/presigned.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ Feature: S3 Presigned Operations
Background:
Given I create a bucket

Scenario: Presigning a get object request
Scenario: Presigning a HTTPS get object request
When I put "signed" to the key "retrieve_me"
And I create a presigned url for "get_object" with:
| key | retrieve_me |
And I send an HTTP get request for the presigned url
Then the response should be "signed"

Scenario: Presinging a HTTP get object request
When I put "signed" to the key "retrieve_me"
And I create a non-secure presigned url for "get_object" with:
| key | retrieve_me |
And I send an HTTP get request for the presigned url
Then the response should be "signed"

Scenario: Presigning a put object request
When I create a presigned url for "put_object" with:
| key | test |
Expand Down
3 changes: 2 additions & 1 deletion aws-sdk-core/features/s3/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ def create_bucket(options = {})
@client.head_object(bucket: @bucket_name, key: @key)
end

When(/^I create a presigned url for "(.*?)" with:$/) do |method, params|
When(/^I create a (non-secure )?presigned url for "(.*?)" with:$/) do |non_secure, method, params|
presigner = Aws::S3::Presigner.new(client: @client)
params = symbolized_params(params)
params[:bucket] = @bucket_name
params[:secure] = false if non_secure
@url = presigner.presigned_url(method.to_sym, params)
end

Expand Down
7 changes: 6 additions & 1 deletion aws-sdk-core/lib/aws-sdk-core/s3/presigner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ def sign_but_dont_send(req, expires_in, scheme)
req.handlers.remove(Plugins::S3RequestSigner::SigningHandler)
req.handlers.remove(Seahorse::Client::Plugins::ContentLength::Handler)
req.handle(step: :send) do |context|
context.http_request.endpoint.scheme = scheme
if scheme != context.http_request.endpoint.scheme
endpoint = context.http_request.endpoint.dup
endpoint.scheme = scheme
endpoint.port = (scheme == 'http' ? 80 : 443)
context.http_request.endpoint = URI.parse(endpoint.to_s)
end
signer = Signers::V4.new(
context.config.credentials, 's3',
context.config.region
Expand Down

0 comments on commit 7a730b3

Please sign in to comment.