Skip to content

Commit

Permalink
S3 and S3v4 case for endpoint properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Oct 6, 2023
1 parent 701d303 commit 16a3f74
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gems/aws-sdk-core/lib/aws-sdk-core/endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def default_auth_scheme(context)
case auth
when 'aws.auth#sigv4', 'aws.auth#sigv4a'
auth_scheme = { 'name' => auth.split('#').last }
if s3_or_s3v4_signature_version?(context)
auth_scheme = auth_scheme.merge(
'disableDoubleEncoding' => true,
'disableNormalizePath' => true
)
end
merge_signing_defaults(auth_scheme, context.config)
when 'smithy.api#httpBearerAuth'
{ 'name' => 'bearer' }
Expand All @@ -72,6 +78,10 @@ def default_api_auth(context)
context.config.api.metadata['auth']
end

def s3_or_s3v4_signature_version?(context)
%w[s3 s3v4].include?(context.config.api.metadata['signatureVersion'])
end

# Legacy auth resolution - looks for deprecated signatureVersion
# and authType traits.

Expand Down
60 changes: 60 additions & 0 deletions gems/aws-sdk-core/spec/aws/endpoints_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ module Aws
expect_auth({ 'name' => 'sigv4' })
client.operation
end

context 's3 signature version' do
let(:signature_version) { 's3' }

it 'disables double encoding and normalize path' do
expect_auth(
{
'name' => 'sigv4',
'disableDoubleEncoding' => true,
'disableNormalizePath' => true
}
)
client.operation
end
end

context 's3v4 signature version' do
let(:signature_version) { 's3v4' }

it 'disables double encoding and normalize path' do
expect_auth(
{
'name' => 'sigv4',
'disableDoubleEncoding' => true,
'disableNormalizePath' => true
}
)
client.operation
end
end
end

context 'sigv4a defaults' do
Expand All @@ -90,6 +120,36 @@ module Aws
expect_auth({ 'name' => 'sigv4a' })
client.operation
end

context 's3 signature version' do
let(:signature_version) { 's3' }

it 'disables double encoding and normalize path' do
expect_auth(
{
'name' => 'sigv4a',
'disableDoubleEncoding' => true,
'disableNormalizePath' => true
}
)
client.operation
end
end

context 's3v4 signature version' do
let(:signature_version) { 's3v4' }

it 'disables double encoding and normalize path' do
expect_auth(
{
'name' => 'sigv4a',
'disableDoubleEncoding' => true,
'disableNormalizePath' => true
}
)
client.operation
end
end
end

context 'bearer defaults' do
Expand Down

0 comments on commit 16a3f74

Please sign in to comment.