aws-sdk-s3 1.103.0 → 1.143.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +288 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/bucket.rb +590 -100
  5. data/lib/aws-sdk-s3/bucket_acl.rb +28 -6
  6. data/lib/aws-sdk-s3/bucket_cors.rb +34 -10
  7. data/lib/aws-sdk-s3/bucket_lifecycle.rb +38 -12
  8. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +42 -12
  9. data/lib/aws-sdk-s3/bucket_logging.rb +35 -6
  10. data/lib/aws-sdk-s3/bucket_notification.rb +27 -9
  11. data/lib/aws-sdk-s3/bucket_policy.rb +78 -10
  12. data/lib/aws-sdk-s3/bucket_request_payment.rb +28 -6
  13. data/lib/aws-sdk-s3/bucket_tagging.rb +34 -10
  14. data/lib/aws-sdk-s3/bucket_versioning.rb +72 -14
  15. data/lib/aws-sdk-s3/bucket_website.rb +34 -10
  16. data/lib/aws-sdk-s3/client.rb +7917 -3171
  17. data/lib/aws-sdk-s3/client_api.rb +709 -224
  18. data/lib/aws-sdk-s3/customizations/bucket.rb +23 -47
  19. data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
  20. data/lib/aws-sdk-s3/customizations/object.rb +171 -22
  21. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  22. data/lib/aws-sdk-s3/customizations.rb +7 -0
  23. data/lib/aws-sdk-s3/encryption/client.rb +6 -2
  24. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
  25. data/lib/aws-sdk-s3/encryptionV2/client.rb +6 -2
  26. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +1 -0
  27. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
  28. data/lib/aws-sdk-s3/endpoint_parameters.rb +178 -0
  29. data/lib/aws-sdk-s3/endpoint_provider.rb +591 -0
  30. data/lib/aws-sdk-s3/endpoints.rb +2590 -0
  31. data/lib/aws-sdk-s3/express_credentials.rb +55 -0
  32. data/lib/aws-sdk-s3/express_credentials_cache.rb +30 -0
  33. data/lib/aws-sdk-s3/express_credentials_provider.rb +36 -0
  34. data/lib/aws-sdk-s3/file_downloader.rb +170 -45
  35. data/lib/aws-sdk-s3/file_uploader.rb +11 -4
  36. data/lib/aws-sdk-s3/multipart_file_uploader.rb +26 -8
  37. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +41 -14
  38. data/lib/aws-sdk-s3/multipart_upload.rb +194 -19
  39. data/lib/aws-sdk-s3/multipart_upload_part.rb +280 -30
  40. data/lib/aws-sdk-s3/object.rb +1735 -266
  41. data/lib/aws-sdk-s3/object_acl.rb +49 -13
  42. data/lib/aws-sdk-s3/object_copier.rb +7 -5
  43. data/lib/aws-sdk-s3/object_multipart_copier.rb +41 -19
  44. data/lib/aws-sdk-s3/object_summary.rb +1497 -221
  45. data/lib/aws-sdk-s3/object_version.rb +365 -58
  46. data/lib/aws-sdk-s3/plugins/accelerate.rb +3 -44
  47. data/lib/aws-sdk-s3/plugins/arn.rb +0 -197
  48. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +3 -39
  49. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +1 -6
  50. data/lib/aws-sdk-s3/plugins/dualstack.rb +1 -55
  51. data/lib/aws-sdk-s3/plugins/endpoints.rb +274 -0
  52. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +2 -1
  53. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +91 -0
  54. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +6 -29
  55. data/lib/aws-sdk-s3/plugins/location_constraint.rb +3 -1
  56. data/lib/aws-sdk-s3/plugins/md5s.rb +6 -3
  57. data/lib/aws-sdk-s3/plugins/s3_signer.rb +35 -109
  58. data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +31 -0
  59. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +23 -2
  60. data/lib/aws-sdk-s3/presigned_post.rb +99 -78
  61. data/lib/aws-sdk-s3/presigner.rb +26 -37
  62. data/lib/aws-sdk-s3/resource.rb +97 -3
  63. data/lib/aws-sdk-s3/types.rb +6618 -4880
  64. data/lib/aws-sdk-s3.rb +5 -1
  65. data/sig/bucket.rbs +212 -0
  66. data/sig/bucket_acl.rbs +78 -0
  67. data/sig/bucket_cors.rbs +69 -0
  68. data/sig/bucket_lifecycle.rbs +88 -0
  69. data/sig/bucket_lifecycle_configuration.rbs +111 -0
  70. data/sig/bucket_logging.rbs +76 -0
  71. data/sig/bucket_notification.rbs +114 -0
  72. data/sig/bucket_policy.rbs +59 -0
  73. data/sig/bucket_request_payment.rbs +54 -0
  74. data/sig/bucket_tagging.rbs +65 -0
  75. data/sig/bucket_versioning.rbs +77 -0
  76. data/sig/bucket_website.rbs +93 -0
  77. data/sig/client.rbs +2360 -0
  78. data/sig/errors.rbs +34 -0
  79. data/sig/multipart_upload.rbs +110 -0
  80. data/sig/multipart_upload_part.rbs +105 -0
  81. data/sig/object.rbs +436 -0
  82. data/sig/object_acl.rbs +86 -0
  83. data/sig/object_summary.rbs +334 -0
  84. data/sig/object_version.rbs +131 -0
  85. data/sig/resource.rbs +124 -0
  86. data/sig/types.rbs +2562 -0
  87. data/sig/waiters.rbs +83 -0
  88. metadata +45 -16
  89. data/lib/aws-sdk-s3/arn/access_point_arn.rb +0 -69
  90. data/lib/aws-sdk-s3/arn/multi_region_access_point_arn.rb +0 -69
  91. data/lib/aws-sdk-s3/arn/object_lambda_arn.rb +0 -69
  92. data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +0 -73
  93. data/lib/aws-sdk-s3/plugins/object_lambda_endpoint.rb +0 -25
@@ -0,0 +1,274 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+
11
+ module Aws::S3
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::S3::EndpointProvider',
17
+ rbs_type: 'untyped',
18
+ docstring: 'The endpoint provider used to resolve endpoints. Any '\
19
+ 'object that responds to `#resolve_endpoint(parameters)` '\
20
+ 'where `parameters` is a Struct similar to '\
21
+ '`Aws::S3::EndpointParameters`'
22
+ ) do |cfg|
23
+ Aws::S3::EndpointProvider.new
24
+ end
25
+
26
+ option(
27
+ :disable_s3_express_session_auth,
28
+ doc_type: 'Boolean',
29
+ default: nil,
30
+ docstring: "Parameter to indicate whether S3Express session auth should be disabled")
31
+
32
+ # @api private
33
+ class Handler < Seahorse::Client::Handler
34
+ def call(context)
35
+ unless context[:discovered_endpoint]
36
+ params = parameters_for_operation(context)
37
+ endpoint = context.config.endpoint_provider.resolve_endpoint(params)
38
+
39
+ context.http_request.endpoint = endpoint.url
40
+ apply_endpoint_headers(context, endpoint.headers)
41
+
42
+ context[:endpoint_params] = params
43
+ context[:endpoint_properties] = endpoint.properties
44
+ end
45
+
46
+ context[:auth_scheme] =
47
+ Aws::Endpoints.resolve_auth_scheme(context, endpoint)
48
+
49
+ @handler.call(context)
50
+ end
51
+
52
+ private
53
+
54
+ def apply_endpoint_headers(context, headers)
55
+ headers.each do |key, values|
56
+ value = values
57
+ .compact
58
+ .map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
59
+ .join(',')
60
+
61
+ context.http_request.headers[key] = value
62
+ end
63
+ end
64
+
65
+ def parameters_for_operation(context)
66
+ case context.operation_name
67
+ when :abort_multipart_upload
68
+ Aws::S3::Endpoints::AbortMultipartUpload.build(context)
69
+ when :complete_multipart_upload
70
+ Aws::S3::Endpoints::CompleteMultipartUpload.build(context)
71
+ when :copy_object
72
+ Aws::S3::Endpoints::CopyObject.build(context)
73
+ when :create_bucket
74
+ Aws::S3::Endpoints::CreateBucket.build(context)
75
+ when :create_multipart_upload
76
+ Aws::S3::Endpoints::CreateMultipartUpload.build(context)
77
+ when :create_session
78
+ Aws::S3::Endpoints::CreateSession.build(context)
79
+ when :delete_bucket
80
+ Aws::S3::Endpoints::DeleteBucket.build(context)
81
+ when :delete_bucket_analytics_configuration
82
+ Aws::S3::Endpoints::DeleteBucketAnalyticsConfiguration.build(context)
83
+ when :delete_bucket_cors
84
+ Aws::S3::Endpoints::DeleteBucketCors.build(context)
85
+ when :delete_bucket_encryption
86
+ Aws::S3::Endpoints::DeleteBucketEncryption.build(context)
87
+ when :delete_bucket_intelligent_tiering_configuration
88
+ Aws::S3::Endpoints::DeleteBucketIntelligentTieringConfiguration.build(context)
89
+ when :delete_bucket_inventory_configuration
90
+ Aws::S3::Endpoints::DeleteBucketInventoryConfiguration.build(context)
91
+ when :delete_bucket_lifecycle
92
+ Aws::S3::Endpoints::DeleteBucketLifecycle.build(context)
93
+ when :delete_bucket_metrics_configuration
94
+ Aws::S3::Endpoints::DeleteBucketMetricsConfiguration.build(context)
95
+ when :delete_bucket_ownership_controls
96
+ Aws::S3::Endpoints::DeleteBucketOwnershipControls.build(context)
97
+ when :delete_bucket_policy
98
+ Aws::S3::Endpoints::DeleteBucketPolicy.build(context)
99
+ when :delete_bucket_replication
100
+ Aws::S3::Endpoints::DeleteBucketReplication.build(context)
101
+ when :delete_bucket_tagging
102
+ Aws::S3::Endpoints::DeleteBucketTagging.build(context)
103
+ when :delete_bucket_website
104
+ Aws::S3::Endpoints::DeleteBucketWebsite.build(context)
105
+ when :delete_object
106
+ Aws::S3::Endpoints::DeleteObject.build(context)
107
+ when :delete_object_tagging
108
+ Aws::S3::Endpoints::DeleteObjectTagging.build(context)
109
+ when :delete_objects
110
+ Aws::S3::Endpoints::DeleteObjects.build(context)
111
+ when :delete_public_access_block
112
+ Aws::S3::Endpoints::DeletePublicAccessBlock.build(context)
113
+ when :get_bucket_accelerate_configuration
114
+ Aws::S3::Endpoints::GetBucketAccelerateConfiguration.build(context)
115
+ when :get_bucket_acl
116
+ Aws::S3::Endpoints::GetBucketAcl.build(context)
117
+ when :get_bucket_analytics_configuration
118
+ Aws::S3::Endpoints::GetBucketAnalyticsConfiguration.build(context)
119
+ when :get_bucket_cors
120
+ Aws::S3::Endpoints::GetBucketCors.build(context)
121
+ when :get_bucket_encryption
122
+ Aws::S3::Endpoints::GetBucketEncryption.build(context)
123
+ when :get_bucket_intelligent_tiering_configuration
124
+ Aws::S3::Endpoints::GetBucketIntelligentTieringConfiguration.build(context)
125
+ when :get_bucket_inventory_configuration
126
+ Aws::S3::Endpoints::GetBucketInventoryConfiguration.build(context)
127
+ when :get_bucket_lifecycle
128
+ Aws::S3::Endpoints::GetBucketLifecycle.build(context)
129
+ when :get_bucket_lifecycle_configuration
130
+ Aws::S3::Endpoints::GetBucketLifecycleConfiguration.build(context)
131
+ when :get_bucket_location
132
+ Aws::S3::Endpoints::GetBucketLocation.build(context)
133
+ when :get_bucket_logging
134
+ Aws::S3::Endpoints::GetBucketLogging.build(context)
135
+ when :get_bucket_metrics_configuration
136
+ Aws::S3::Endpoints::GetBucketMetricsConfiguration.build(context)
137
+ when :get_bucket_notification
138
+ Aws::S3::Endpoints::GetBucketNotification.build(context)
139
+ when :get_bucket_notification_configuration
140
+ Aws::S3::Endpoints::GetBucketNotificationConfiguration.build(context)
141
+ when :get_bucket_ownership_controls
142
+ Aws::S3::Endpoints::GetBucketOwnershipControls.build(context)
143
+ when :get_bucket_policy
144
+ Aws::S3::Endpoints::GetBucketPolicy.build(context)
145
+ when :get_bucket_policy_status
146
+ Aws::S3::Endpoints::GetBucketPolicyStatus.build(context)
147
+ when :get_bucket_replication
148
+ Aws::S3::Endpoints::GetBucketReplication.build(context)
149
+ when :get_bucket_request_payment
150
+ Aws::S3::Endpoints::GetBucketRequestPayment.build(context)
151
+ when :get_bucket_tagging
152
+ Aws::S3::Endpoints::GetBucketTagging.build(context)
153
+ when :get_bucket_versioning
154
+ Aws::S3::Endpoints::GetBucketVersioning.build(context)
155
+ when :get_bucket_website
156
+ Aws::S3::Endpoints::GetBucketWebsite.build(context)
157
+ when :get_object
158
+ Aws::S3::Endpoints::GetObject.build(context)
159
+ when :get_object_acl
160
+ Aws::S3::Endpoints::GetObjectAcl.build(context)
161
+ when :get_object_attributes
162
+ Aws::S3::Endpoints::GetObjectAttributes.build(context)
163
+ when :get_object_legal_hold
164
+ Aws::S3::Endpoints::GetObjectLegalHold.build(context)
165
+ when :get_object_lock_configuration
166
+ Aws::S3::Endpoints::GetObjectLockConfiguration.build(context)
167
+ when :get_object_retention
168
+ Aws::S3::Endpoints::GetObjectRetention.build(context)
169
+ when :get_object_tagging
170
+ Aws::S3::Endpoints::GetObjectTagging.build(context)
171
+ when :get_object_torrent
172
+ Aws::S3::Endpoints::GetObjectTorrent.build(context)
173
+ when :get_public_access_block
174
+ Aws::S3::Endpoints::GetPublicAccessBlock.build(context)
175
+ when :head_bucket
176
+ Aws::S3::Endpoints::HeadBucket.build(context)
177
+ when :head_object
178
+ Aws::S3::Endpoints::HeadObject.build(context)
179
+ when :list_bucket_analytics_configurations
180
+ Aws::S3::Endpoints::ListBucketAnalyticsConfigurations.build(context)
181
+ when :list_bucket_intelligent_tiering_configurations
182
+ Aws::S3::Endpoints::ListBucketIntelligentTieringConfigurations.build(context)
183
+ when :list_bucket_inventory_configurations
184
+ Aws::S3::Endpoints::ListBucketInventoryConfigurations.build(context)
185
+ when :list_bucket_metrics_configurations
186
+ Aws::S3::Endpoints::ListBucketMetricsConfigurations.build(context)
187
+ when :list_buckets
188
+ Aws::S3::Endpoints::ListBuckets.build(context)
189
+ when :list_directory_buckets
190
+ Aws::S3::Endpoints::ListDirectoryBuckets.build(context)
191
+ when :list_multipart_uploads
192
+ Aws::S3::Endpoints::ListMultipartUploads.build(context)
193
+ when :list_object_versions
194
+ Aws::S3::Endpoints::ListObjectVersions.build(context)
195
+ when :list_objects
196
+ Aws::S3::Endpoints::ListObjects.build(context)
197
+ when :list_objects_v2
198
+ Aws::S3::Endpoints::ListObjectsV2.build(context)
199
+ when :list_parts
200
+ Aws::S3::Endpoints::ListParts.build(context)
201
+ when :put_bucket_accelerate_configuration
202
+ Aws::S3::Endpoints::PutBucketAccelerateConfiguration.build(context)
203
+ when :put_bucket_acl
204
+ Aws::S3::Endpoints::PutBucketAcl.build(context)
205
+ when :put_bucket_analytics_configuration
206
+ Aws::S3::Endpoints::PutBucketAnalyticsConfiguration.build(context)
207
+ when :put_bucket_cors
208
+ Aws::S3::Endpoints::PutBucketCors.build(context)
209
+ when :put_bucket_encryption
210
+ Aws::S3::Endpoints::PutBucketEncryption.build(context)
211
+ when :put_bucket_intelligent_tiering_configuration
212
+ Aws::S3::Endpoints::PutBucketIntelligentTieringConfiguration.build(context)
213
+ when :put_bucket_inventory_configuration
214
+ Aws::S3::Endpoints::PutBucketInventoryConfiguration.build(context)
215
+ when :put_bucket_lifecycle
216
+ Aws::S3::Endpoints::PutBucketLifecycle.build(context)
217
+ when :put_bucket_lifecycle_configuration
218
+ Aws::S3::Endpoints::PutBucketLifecycleConfiguration.build(context)
219
+ when :put_bucket_logging
220
+ Aws::S3::Endpoints::PutBucketLogging.build(context)
221
+ when :put_bucket_metrics_configuration
222
+ Aws::S3::Endpoints::PutBucketMetricsConfiguration.build(context)
223
+ when :put_bucket_notification
224
+ Aws::S3::Endpoints::PutBucketNotification.build(context)
225
+ when :put_bucket_notification_configuration
226
+ Aws::S3::Endpoints::PutBucketNotificationConfiguration.build(context)
227
+ when :put_bucket_ownership_controls
228
+ Aws::S3::Endpoints::PutBucketOwnershipControls.build(context)
229
+ when :put_bucket_policy
230
+ Aws::S3::Endpoints::PutBucketPolicy.build(context)
231
+ when :put_bucket_replication
232
+ Aws::S3::Endpoints::PutBucketReplication.build(context)
233
+ when :put_bucket_request_payment
234
+ Aws::S3::Endpoints::PutBucketRequestPayment.build(context)
235
+ when :put_bucket_tagging
236
+ Aws::S3::Endpoints::PutBucketTagging.build(context)
237
+ when :put_bucket_versioning
238
+ Aws::S3::Endpoints::PutBucketVersioning.build(context)
239
+ when :put_bucket_website
240
+ Aws::S3::Endpoints::PutBucketWebsite.build(context)
241
+ when :put_object
242
+ Aws::S3::Endpoints::PutObject.build(context)
243
+ when :put_object_acl
244
+ Aws::S3::Endpoints::PutObjectAcl.build(context)
245
+ when :put_object_legal_hold
246
+ Aws::S3::Endpoints::PutObjectLegalHold.build(context)
247
+ when :put_object_lock_configuration
248
+ Aws::S3::Endpoints::PutObjectLockConfiguration.build(context)
249
+ when :put_object_retention
250
+ Aws::S3::Endpoints::PutObjectRetention.build(context)
251
+ when :put_object_tagging
252
+ Aws::S3::Endpoints::PutObjectTagging.build(context)
253
+ when :put_public_access_block
254
+ Aws::S3::Endpoints::PutPublicAccessBlock.build(context)
255
+ when :restore_object
256
+ Aws::S3::Endpoints::RestoreObject.build(context)
257
+ when :select_object_content
258
+ Aws::S3::Endpoints::SelectObjectContent.build(context)
259
+ when :upload_part
260
+ Aws::S3::Endpoints::UploadPart.build(context)
261
+ when :upload_part_copy
262
+ Aws::S3::Endpoints::UploadPartCopy.build(context)
263
+ when :write_get_object_response
264
+ Aws::S3::Endpoints::WriteGetObjectResponse.build(context)
265
+ end
266
+ end
267
+ end
268
+
269
+ def add_handlers(handlers, _config)
270
+ handlers.add(Handler, step: :build, priority: 75)
271
+ end
272
+ end
273
+ end
274
+ end
@@ -16,7 +16,8 @@ module Aws
16
16
 
17
17
  def call(context)
18
18
  body = context.http_request.body
19
- if body.respond_to?(:size) && body.size > 0
19
+ if body.respond_to?(:size) && body.size > 0 &&
20
+ !context[:use_accelerate_endpoint]
20
21
  context.http_request.headers['expect'] = '100-continue'
21
22
  end
22
23
  @handler.call(context)
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Plugins
6
+ # @api private
7
+ class ExpressSessionAuth < Seahorse::Client::Plugin
8
+ # This should be s3_disable_express_auth instead
9
+ # But this is not a built in. We're overwriting the generated value
10
+ option(:disable_s3_express_session_auth,
11
+ default: false,
12
+ doc_type: 'Boolean',
13
+ docstring: <<-DOCS) do |cfg|
14
+ When `true`, S3 Express session authentication is disabled.
15
+ DOCS
16
+ resolve_disable_s3_express_session_auth(cfg)
17
+ end
18
+
19
+ option(:express_credentials_provider,
20
+ doc_type: 'Aws::S3::ExpressCredentialsProvider',
21
+ rbs_type: 'untyped',
22
+ docstring: <<-DOCS) do |_cfg|
23
+ Credential Provider for S3 Express endpoints. Manages credentials
24
+ for different buckets.
25
+ DOCS
26
+ Aws::S3::ExpressCredentialsProvider.new
27
+ end
28
+
29
+ # @api private
30
+ class Handler < Seahorse::Client::Handler
31
+ def call(context)
32
+ if (props = context[:endpoint_properties])
33
+ # S3 Express endpoint - turn off md5 and enable crc32 default
34
+ if (backend = props['backend']) && backend == 'S3Express'
35
+ if context.operation_name == :put_object || checksum_required?(context)
36
+ context[:default_request_checksum_algorithm] = 'CRC32'
37
+ end
38
+ context[:s3_express_endpoint] = true
39
+ end
40
+
41
+ # if s3 express auth, use new credentials and sign additional header
42
+ if context[:auth_scheme]['name'] == 'sigv4-s3express' &&
43
+ !context.config.disable_s3_express_session_auth
44
+ bucket = context.params[:bucket]
45
+ credentials_provider = context.config.express_credentials_provider
46
+ credentials = credentials_provider.express_credentials_for(bucket)
47
+ context[:sigv4_credentials] = credentials # Sign will use this
48
+ end
49
+ end
50
+ @handler.call(context)
51
+ end
52
+
53
+ private
54
+
55
+ def checksum_required?(context)
56
+ context.operation.http_checksum_required ||
57
+ (context.operation.http_checksum &&
58
+ context.operation.http_checksum['requestChecksumRequired'])
59
+ end
60
+ end
61
+
62
+ handler(Handler)
63
+
64
+ # Optimization - sets this client as the client to create sessions.
65
+ def after_initialize(client)
66
+ provider = client.config.express_credentials_provider
67
+ provider.client = client unless provider.client
68
+ end
69
+
70
+ class << self
71
+ private
72
+
73
+ def resolve_disable_s3_express_session_auth(cfg)
74
+ value = ENV['AWS_S3_DISABLE_EXPRESS_SESSION_AUTH'] ||
75
+ Aws.shared_config.s3_disable_express_session_auth(profile: cfg.profile) ||
76
+ 'false'
77
+ value = Aws::Util.str_2_bool(value)
78
+ # Raise if provided value is not true or false
79
+ if value.nil?
80
+ raise ArgumentError,
81
+ 'Must provide either `true` or `false` for the '\
82
+ '`s3_disable_express_session_auth` profile option or for '\
83
+ "ENV['AWS_S3_DISABLE_EXPRESS_SESSION_AUTH']."
84
+ end
85
+ value
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -16,40 +16,17 @@ Defaults to `legacy` mode which uses the global endpoint.
16
16
  resolve_iad_regional_endpoint(cfg)
17
17
  end
18
18
 
19
- def add_handlers(handlers, config)
20
- # only modify non-custom endpoints
21
- if config.regional_endpoint && config.region == 'us-east-1'
22
- handlers.add(Handler)
23
- end
24
- end
25
-
26
- # @api private
27
- class Handler < Seahorse::Client::Handler
28
-
29
- def call(context)
30
- # WriteGetObjectResponse does not have a global endpoint
31
- # ARNs are regionalized, so don't touch those either.
32
- if context.operation.name != 'WriteGetObjectResponse' &&
33
- context.config.s3_us_east_1_regional_endpoint == 'legacy' &&
34
- !context.metadata[:s3_arn]
35
- host = context.http_request.endpoint.host
36
- legacy_host = IADRegionalEndpoint.legacy_host(host)
37
- context.http_request.endpoint.host = legacy_host
38
- end
39
- @handler.call(context)
40
- end
41
-
42
- end
43
-
44
- def self.legacy_host(host)
45
- host.sub(".us-east-1", '')
46
- end
47
-
48
19
  private
49
20
 
50
21
  def self.resolve_iad_regional_endpoint(cfg)
22
+ default_mode_value =
23
+ if cfg.respond_to?(:defaults_mode_config_resolver)
24
+ cfg.defaults_mode_config_resolver.resolve(:s3_us_east_1_regional_endpoint)
25
+ end
26
+
51
27
  mode = ENV['AWS_S3_US_EAST_1_REGIONAL_ENDPOINT'] ||
52
28
  Aws.shared_config.s3_us_east_1_regional_endpoint(profile: cfg.profile) ||
29
+ default_mode_value ||
53
30
  'legacy'
54
31
  mode = mode.downcase
55
32
  unless %w(legacy regional).include?(mode)
@@ -22,7 +22,9 @@ module Aws
22
22
 
23
23
  def populate_location_constraint(params, region)
24
24
  params[:create_bucket_configuration] ||= {}
25
- params[:create_bucket_configuration][:location_constraint] ||= region
25
+ unless params[:create_bucket_configuration][:location]
26
+ params[:create_bucket_configuration][:location_constraint] ||= region
27
+ end
26
28
  end
27
29
 
28
30
  end
@@ -22,9 +22,12 @@ module Aws
22
22
  CHUNK_SIZE = 1 * 1024 * 1024 # one MB
23
23
 
24
24
  def call(context)
25
- body = context.http_request.body
26
- if body.respond_to?(:size) && body.size > 0
27
- context.http_request.headers['Content-Md5'] ||= md5(body)
25
+ if !context[:checksum_algorithms] && # skip in favor of flexible checksum
26
+ !context[:s3_express_endpoint] # s3 express endpoints do not support md5
27
+ body = context.http_request.body
28
+ if body.respond_to?(:size) && body.size > 0
29
+ context.http_request.headers['Content-Md5'] ||= md5(body)
30
+ end
28
31
  end
29
32
  @handler.call(context)
30
33
  end
@@ -5,26 +5,13 @@ require 'aws-sigv4'
5
5
  module Aws
6
6
  module S3
7
7
  module Plugins
8
- # This plugin is an implementation detail and may be modified.
8
+ # This plugin used to have a V4 signer but it was removed in favor of
9
+ # generic Sign plugin that uses endpoint auth scheme.
10
+ #
9
11
  # @api private
10
12
  class S3Signer < Seahorse::Client::Plugin
11
13
  option(:signature_version, 'v4')
12
14
 
13
- option(:sigv4_signer) do |cfg|
14
- S3Signer.build_v4_signer(
15
- service: 's3',
16
- region: cfg.sigv4_region,
17
- credentials: cfg.credentials
18
- )
19
- end
20
-
21
- option(:sigv4_region) do |cfg|
22
- # S3 removes core's signature_v4 plugin that checks for this
23
- raise Aws::Errors::MissingRegionError if cfg.region.nil?
24
-
25
- Aws::Partitions::EndpointProvider.signing_region(cfg.region, 's3')
26
- end
27
-
28
15
  def add_handlers(handlers, cfg)
29
16
  case cfg.signature_version
30
17
  when 'v4' then add_v4_handlers(handlers)
@@ -37,11 +24,11 @@ module Aws
37
24
 
38
25
  def add_v4_handlers(handlers)
39
26
  handlers.add(CachedBucketRegionHandler, step: :sign, priority: 60)
40
- handlers.add(V4Handler, step: :sign)
41
27
  handlers.add(BucketRegionErrorHandler, step: :sign, priority: 40)
42
28
  end
43
29
 
44
30
  def add_legacy_handler(handlers)
31
+ # generic Sign plugin will be skipped if it sees sigv2
45
32
  handlers.add(LegacyHandler, step: :sign)
46
33
  end
47
34
 
@@ -52,53 +39,6 @@ module Aws
52
39
  end
53
40
  end
54
41
 
55
- class V4Handler < Seahorse::Client::Handler
56
- def call(context)
57
- Aws::Plugins::SignatureV4.apply_signature(
58
- context: context,
59
- signer: sigv4_signer(context)
60
- )
61
- @handler.call(context)
62
- end
63
-
64
- private
65
-
66
- def sigv4_signer(context)
67
- # If the client was configured with the wrong region,
68
- # we have to build a new signer.
69
- if context[:cached_sigv4_region] &&
70
- context[:cached_sigv4_region] != context.config.sigv4_signer.region
71
- S3Signer.build_v4_signer(
72
- service: 's3',
73
- region: context[:cached_sigv4_region],
74
- credentials: context.config.credentials
75
- )
76
- elsif (arn = context.metadata[:s3_arn])
77
- if arn[:arn].is_a?(MultiRegionAccessPointARN)
78
- signing_region = '*'
79
- signing_algorithm = :sigv4a
80
- else
81
- signing_region = arn[:resolved_region]
82
- signing_algorithm = :sigv4
83
- end
84
- S3Signer.build_v4_signer(
85
- service: arn[:arn].service,
86
- signing_algorithm: signing_algorithm,
87
- region: signing_region,
88
- credentials: context.config.credentials
89
- )
90
- elsif context.operation.name == 'WriteGetObjectResponse'
91
- S3Signer.build_v4_signer(
92
- service: 's3-object-lambda',
93
- region: context.config.sigv4_region,
94
- credentials: context.config.credentials
95
- )
96
- else
97
- context.config.sigv4_signer
98
- end
99
- end
100
- end
101
-
102
42
  # This handler will update the http endpoint when the bucket region
103
43
  # is known/cached.
104
44
  class CachedBucketRegionHandler < Seahorse::Client::Handler
@@ -112,11 +52,13 @@ module Aws
112
52
 
113
53
  def check_for_cached_region(context, bucket)
114
54
  cached_region = S3::BUCKET_REGIONS[bucket]
115
- if cached_region && cached_region != context.config.region
55
+ if cached_region &&
56
+ cached_region != context.config.region &&
57
+ !S3Signer.custom_endpoint?(context)
116
58
  context.http_request.endpoint.host = S3Signer.new_hostname(
117
59
  context, cached_region
118
60
  )
119
- context[:cached_sigv4_region] = cached_region
61
+ context[:sigv4_region] = cached_region # Sign plugin will use this
120
62
  end
121
63
  end
122
64
  end
@@ -124,7 +66,8 @@ module Aws
124
66
  # This handler detects when a request fails because of a mismatched bucket
125
67
  # region. It follows up by making a request to determine the correct
126
68
  # region, then finally a version 4 signed request against the correct
127
- # regional endpoint.
69
+ # regional endpoint. This is intended for s3's global endpoint which
70
+ # will return 400 if the bucket is not in region.
128
71
  class BucketRegionErrorHandler < Seahorse::Client::Handler
129
72
  def call(context)
130
73
  response = @handler.call(context)
@@ -136,7 +79,8 @@ module Aws
136
79
  def handle_region_errors(response)
137
80
  if wrong_sigv4_region?(response) &&
138
81
  !fips_region?(response) &&
139
- !custom_endpoint?(response)
82
+ !S3Signer.custom_endpoint?(response.context) &&
83
+ !expired_credentials?(response)
140
84
  get_region_and_retry(response.context)
141
85
  else
142
86
  response
@@ -157,14 +101,11 @@ module Aws
157
101
  end
158
102
 
159
103
  def fips_region?(resp)
160
- resp.context.http_request.endpoint.host.include?('fips')
104
+ resp.context.http_request.endpoint.host.include?('s3-fips.')
161
105
  end
162
106
 
163
- def custom_endpoint?(resp)
164
- resolved_suffix = Aws::Partitions::EndpointProvider.dns_suffix_for(
165
- resp.context.config.region
166
- )
167
- !resp.context.http_request.endpoint.hostname.include?(resolved_suffix)
107
+ def expired_credentials?(resp)
108
+ resp.context.http_response.body_contents.match(/<Code>ExpiredToken<\/Code>/)
168
109
  end
169
110
 
170
111
  def wrong_sigv4_region?(resp)
@@ -179,18 +120,14 @@ module Aws
179
120
  context, actual_region
180
121
  )
181
122
  context.metadata[:redirect_region] = actual_region
182
- # if it's an ARN, use the service in the ARN
183
- if (arn = context.metadata[:s3_arn])
184
- service = arn[:arn].service
185
- end
186
- Aws::Plugins::SignatureV4.apply_signature(
187
- context: context,
188
- signer: S3Signer.build_v4_signer(
189
- service: service || 's3',
190
- region: actual_region,
191
- credentials: context.config.credentials
192
- )
123
+
124
+ signer = Aws::Plugins::Sign.signer_for(
125
+ context[:auth_scheme],
126
+ context.config,
127
+ actual_region
193
128
  )
129
+
130
+ signer.sign(context)
194
131
  end
195
132
 
196
133
  def region_from_body(body)
@@ -216,33 +153,22 @@ module Aws
216
153
  end
217
154
 
218
155
  class << self
219
- # @option options [required, String] :region
220
- # @option options [required, #credentials] :credentials
221
- # @api private
222
- def build_v4_signer(options = {})
223
- Aws::Sigv4::Signer.new(
224
- service: options[:service],
225
- region: options[:region],
226
- credentials_provider: options[:credentials],
227
- signing_algorithm: options.fetch(:signing_algorithm, :sigv4),
228
- uri_escape_path: false,
229
- unsigned_headers: ['content-length', 'x-amzn-trace-id']
230
- )
156
+ def new_hostname(context, region)
157
+ endpoint_params = context[:endpoint_params].dup
158
+ endpoint_params.region = region
159
+ endpoint_params.endpoint = nil
160
+ endpoint =
161
+ context.config.endpoint_provider.resolve_endpoint(endpoint_params)
162
+ URI(endpoint.url).host
231
163
  end
232
164
 
233
- # Check to see if the bucket is actually an ARN
234
- # Otherwise it will retry with the ARN as the bucket name.
235
- def new_hostname(context, region)
236
- uri = URI.parse(
237
- Aws::Partitions::EndpointProvider.resolve(region, 's3')
238
- )
165
+ def custom_endpoint?(context)
166
+ region = context.config.region
167
+ partition = Aws::Endpoints::Matchers.aws_partition(region)
168
+ endpoint = context.http_request.endpoint
239
169
 
240
- if (arn = context.metadata[:s3_arn])
241
- # Retry with the response region and not the ARN resolved one
242
- ARN.resolve_url!(uri, arn[:arn], region).host
243
- else
244
- "#{context.params[:bucket]}.#{uri.host}"
245
- end
170
+ !endpoint.hostname.include?(partition['dnsSuffix']) &&
171
+ !endpoint.hostname.include?(partition['dualStackDnsSuffix'])
246
172
  end
247
173
  end
248
174
  end