aws-sdk-s3 1.136.0 → 1.176.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +250 -1
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/access_grants_credentials.rb +57 -0
- data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +250 -0
- data/lib/aws-sdk-s3/bucket.rb +671 -139
- data/lib/aws-sdk-s3/bucket_acl.rb +12 -12
- data/lib/aws-sdk-s3/bucket_cors.rb +16 -16
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +21 -16
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +74 -17
- data/lib/aws-sdk-s3/bucket_logging.rb +19 -12
- data/lib/aws-sdk-s3/bucket_notification.rb +6 -6
- data/lib/aws-sdk-s3/bucket_policy.rb +62 -18
- data/lib/aws-sdk-s3/bucket_region_cache.rb +9 -5
- data/lib/aws-sdk-s3/bucket_request_payment.rb +12 -12
- data/lib/aws-sdk-s3/bucket_tagging.rb +16 -16
- data/lib/aws-sdk-s3/bucket_versioning.rb +32 -32
- data/lib/aws-sdk-s3/bucket_website.rb +16 -16
- data/lib/aws-sdk-s3/client.rb +7597 -2823
- data/lib/aws-sdk-s3/client_api.rb +288 -22
- data/lib/aws-sdk-s3/customizations/bucket.rb +1 -1
- data/lib/aws-sdk-s3/customizations/errors.rb +15 -2
- data/lib/aws-sdk-s3/customizations/object.rb +11 -5
- data/lib/aws-sdk-s3/customizations/object_summary.rb +5 -0
- data/lib/aws-sdk-s3/customizations/object_version.rb +13 -0
- data/lib/aws-sdk-s3/customizations.rb +25 -31
- data/lib/aws-sdk-s3/encryption/client.rb +2 -2
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +2 -2
- data/lib/aws-sdk-s3/encryptionV2/client.rb +2 -2
- data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +2 -2
- data/lib/aws-sdk-s3/endpoint_parameters.rb +53 -18
- data/lib/aws-sdk-s3/endpoint_provider.rb +125 -6
- data/lib/aws-sdk-s3/endpoints.rb +545 -1261
- data/lib/aws-sdk-s3/errors.rb +47 -0
- data/lib/aws-sdk-s3/express_credentials.rb +55 -0
- data/lib/aws-sdk-s3/express_credentials_provider.rb +59 -0
- data/lib/aws-sdk-s3/file_downloader.rb +1 -2
- data/lib/aws-sdk-s3/file_uploader.rb +1 -1
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +4 -4
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +6 -5
- data/lib/aws-sdk-s3/multipart_upload.rb +139 -36
- data/lib/aws-sdk-s3/multipart_upload_part.rb +175 -54
- data/lib/aws-sdk-s3/object.rb +1923 -313
- data/lib/aws-sdk-s3/object_acl.rb +34 -22
- data/lib/aws-sdk-s3/object_copier.rb +1 -1
- data/lib/aws-sdk-s3/object_multipart_copier.rb +10 -8
- data/lib/aws-sdk-s3/object_summary.rb +1690 -250
- data/lib/aws-sdk-s3/object_version.rb +397 -67
- data/lib/aws-sdk-s3/plugins/access_grants.rb +178 -0
- data/lib/aws-sdk-s3/plugins/endpoints.rb +32 -208
- data/lib/aws-sdk-s3/plugins/express_session_auth.rb +97 -0
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +55 -18
- data/lib/aws-sdk-s3/plugins/location_constraint.rb +3 -1
- data/lib/aws-sdk-s3/plugins/md5s.rb +2 -1
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +7 -2
- data/lib/aws-sdk-s3/presigner.rb +5 -2
- data/lib/aws-sdk-s3/resource.rb +121 -22
- data/lib/aws-sdk-s3/types.rb +5960 -1526
- data/lib/aws-sdk-s3.rb +35 -31
- data/sig/bucket.rbs +221 -0
- data/sig/bucket_acl.rbs +78 -0
- data/sig/bucket_cors.rbs +69 -0
- data/sig/bucket_lifecycle.rbs +88 -0
- data/sig/bucket_lifecycle_configuration.rbs +115 -0
- data/sig/bucket_logging.rbs +76 -0
- data/sig/bucket_notification.rbs +114 -0
- data/sig/bucket_policy.rbs +59 -0
- data/sig/bucket_request_payment.rbs +54 -0
- data/sig/bucket_tagging.rbs +65 -0
- data/sig/bucket_versioning.rbs +77 -0
- data/sig/bucket_website.rbs +93 -0
- data/sig/client.rbs +2450 -0
- data/sig/customizations/bucket.rbs +19 -0
- data/sig/customizations/object.rbs +38 -0
- data/sig/customizations/object_summary.rbs +35 -0
- data/sig/errors.rbs +42 -0
- data/sig/multipart_upload.rbs +113 -0
- data/sig/multipart_upload_part.rbs +105 -0
- data/sig/object.rbs +448 -0
- data/sig/object_acl.rbs +86 -0
- data/sig/object_summary.rbs +340 -0
- data/sig/object_version.rbs +140 -0
- data/sig/resource.rbs +132 -0
- data/sig/types.rbs +2682 -0
- data/sig/waiters.rbs +95 -0
- metadata +44 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6549eea72ce7643897ce882d77e1c563d04d8bc64c31195eea0692eba98a9771
|
4
|
+
data.tar.gz: 7662c9e60f2f3cc42f03c2dfd300426a0c57f199ca2e8d0a88239c95a6b7fc99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb6e5e889aa5031deaf66f795f0ad211295064bb850464944ad88c33d4f4660db8abf42fdd10816dee17fc2d99f3c221334ff7dcf87a3efb34073f4090a8ac7
|
7
|
+
data.tar.gz: 6f76df44f96c1ab0fd5c5a4ee372ed5c659ed326362cfdce7cd7ead1919df5dffcf6ff947c4595e94064a3fdc20a51247da6c03b98203d0e95ecf74cd1ec9aae
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,254 @@
|
|
1
1
|
Unreleased Changes
|
2
2
|
------------------
|
3
3
|
|
4
|
+
1.176.1 (2024-12-12)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* Issue - Do not normalize object keys when calling `presigned_url` or `presigned_request`.
|
8
|
+
|
9
|
+
1.176.0 (2024-12-03)
|
10
|
+
------------------
|
11
|
+
|
12
|
+
* Feature - Amazon S3 Metadata stores object metadata in read-only, fully managed Apache Iceberg metadata tables that you can query. You can create metadata table configurations for S3 general purpose buckets.
|
13
|
+
|
14
|
+
1.175.0 (2024-12-02)
|
15
|
+
------------------
|
16
|
+
|
17
|
+
* Feature - Amazon S3 introduces support for AWS Dedicated Local Zones
|
18
|
+
|
19
|
+
1.174.0 (2024-11-25)
|
20
|
+
------------------
|
21
|
+
|
22
|
+
* Feature - Amazon Simple Storage Service / Features: Add support for ETag based conditional writes in PutObject and CompleteMultiPartUpload APIs to prevent unintended object modifications.
|
23
|
+
|
24
|
+
1.173.0 (2024-11-21)
|
25
|
+
------------------
|
26
|
+
|
27
|
+
* Feature - Add support for conditional deletes for the S3 DeleteObject and DeleteObjects APIs. Add support for write offset bytes option used to append to objects with the S3 PutObject API.
|
28
|
+
|
29
|
+
1.172.0 (2024-11-18)
|
30
|
+
------------------
|
31
|
+
|
32
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
33
|
+
|
34
|
+
1.171.0 (2024-11-14)
|
35
|
+
------------------
|
36
|
+
|
37
|
+
* Feature - This release updates the ListBuckets API Reference documentation in support of the new 10,000 general purpose bucket default quota on all AWS accounts. To increase your bucket quota from 10,000 to up to 1 million buckets, simply request a quota increase via Service Quotas.
|
38
|
+
|
39
|
+
1.170.1 (2024-11-11)
|
40
|
+
------------------
|
41
|
+
|
42
|
+
* Issue - Tighten regex used to check for S3 200 errors.
|
43
|
+
|
44
|
+
1.170.0 (2024-11-06)
|
45
|
+
------------------
|
46
|
+
|
47
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
48
|
+
|
49
|
+
1.169.0 (2024-10-18)
|
50
|
+
------------------
|
51
|
+
|
52
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
53
|
+
|
54
|
+
1.168.0 (2024-10-16)
|
55
|
+
------------------
|
56
|
+
|
57
|
+
* Feature - Add support for the new optional bucket-region and prefix query parameters in the ListBuckets API. For ListBuckets requests that express pagination, Amazon S3 will now return both the bucket names and associated AWS regions in the response.
|
58
|
+
|
59
|
+
1.167.0 (2024-10-02)
|
60
|
+
------------------
|
61
|
+
|
62
|
+
* Feature - This release introduces a header representing the minimum object size limit for Lifecycle transitions.
|
63
|
+
|
64
|
+
1.166.0 (2024-09-24)
|
65
|
+
------------------
|
66
|
+
|
67
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
68
|
+
|
69
|
+
1.165.0 (2024-09-23)
|
70
|
+
------------------
|
71
|
+
|
72
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
73
|
+
|
74
|
+
1.164.0 (2024-09-20)
|
75
|
+
------------------
|
76
|
+
|
77
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
78
|
+
|
79
|
+
1.163.0 (2024-09-18)
|
80
|
+
------------------
|
81
|
+
|
82
|
+
* Feature - Added SSE-KMS support for directory buckets.
|
83
|
+
|
84
|
+
1.162.0 (2024-09-11)
|
85
|
+
------------------
|
86
|
+
|
87
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
88
|
+
|
89
|
+
1.161.0 (2024-09-10)
|
90
|
+
------------------
|
91
|
+
|
92
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
93
|
+
|
94
|
+
1.160.0 (2024-09-03)
|
95
|
+
------------------
|
96
|
+
|
97
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
98
|
+
|
99
|
+
1.159.0 (2024-08-20)
|
100
|
+
------------------
|
101
|
+
|
102
|
+
* Feature - Amazon Simple Storage Service / Features : Add support for conditional writes for PutObject and CompleteMultipartUpload APIs.
|
103
|
+
|
104
|
+
1.158.0 (2024-08-15)
|
105
|
+
------------------
|
106
|
+
|
107
|
+
* Feature - Amazon Simple Storage Service / Features : Adds support for pagination in the S3 ListBuckets API.
|
108
|
+
|
109
|
+
1.157.0 (2024-08-01)
|
110
|
+
------------------
|
111
|
+
|
112
|
+
* Feature - Support `head_bucket`, `get_object_attributes`, `delete_objects`, and `copy_object` for Access Grants.
|
113
|
+
|
114
|
+
1.156.0 (2024-07-02)
|
115
|
+
------------------
|
116
|
+
|
117
|
+
* Feature - Added response overrides to Head Object requests.
|
118
|
+
|
119
|
+
1.155.0 (2024-06-28)
|
120
|
+
------------------
|
121
|
+
|
122
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
123
|
+
|
124
|
+
1.154.0 (2024-06-25)
|
125
|
+
------------------
|
126
|
+
|
127
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
128
|
+
|
129
|
+
1.153.0 (2024-06-24)
|
130
|
+
------------------
|
131
|
+
|
132
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
133
|
+
|
134
|
+
1.152.3 (2024-06-13)
|
135
|
+
------------------
|
136
|
+
|
137
|
+
* Issue - Handle 200 errors for all S3 operations that do not have streaming responses.
|
138
|
+
|
139
|
+
1.152.2 (2024-06-12)
|
140
|
+
------------------
|
141
|
+
|
142
|
+
* Issue - Revert Handling of 200 errors for all S3 operations.
|
143
|
+
|
144
|
+
1.152.1 (2024-06-10)
|
145
|
+
------------------
|
146
|
+
|
147
|
+
* Issue - Handle 200 errors for all S3 operations that do not have streaming responses.
|
148
|
+
|
149
|
+
1.152.0 (2024-06-05)
|
150
|
+
------------------
|
151
|
+
|
152
|
+
* Feature - Added new params copySource and key to copyObject API for supporting S3 Access Grants plugin. These changes will not change any of the existing S3 API functionality.
|
153
|
+
|
154
|
+
1.151.0 (2024-05-14)
|
155
|
+
------------------
|
156
|
+
|
157
|
+
* Feature - Updated a few x-id in the http uri traits
|
158
|
+
|
159
|
+
1.150.0 (2024-05-13)
|
160
|
+
------------------
|
161
|
+
|
162
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
163
|
+
|
164
|
+
1.149.1 (2024-05-06)
|
165
|
+
------------------
|
166
|
+
|
167
|
+
* Issue - Fix bug where destination bucket default encryption was inadvertently overridden by source object encryption.
|
168
|
+
|
169
|
+
1.149.0 (2024-04-30)
|
170
|
+
------------------
|
171
|
+
|
172
|
+
* Feature - Support S3 Access Grants authentication. Access Grants can be enabled with the `access_grants` option, and custom options can be passed into the `access_grants_credentials_provider` option. This feature requires `aws-sdk-s3control` to be installed.
|
173
|
+
|
174
|
+
* Feature - Add RBS signatures for customizations of S3.
|
175
|
+
|
176
|
+
1.148.0 (2024-04-25)
|
177
|
+
------------------
|
178
|
+
|
179
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
180
|
+
|
181
|
+
1.147.0 (2024-04-16)
|
182
|
+
------------------
|
183
|
+
|
184
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
185
|
+
|
186
|
+
* Issue - Omit `ContentType` plugin when generating presigned url.
|
187
|
+
|
188
|
+
1.146.1 (2024-03-28)
|
189
|
+
------------------
|
190
|
+
|
191
|
+
* Issue - Fix bug where thread_count option was not being respected for multipart uploads.
|
192
|
+
|
193
|
+
1.146.0 (2024-03-18)
|
194
|
+
------------------
|
195
|
+
|
196
|
+
* Feature - Fix two issues with response root node names.
|
197
|
+
|
198
|
+
1.145.0 (2024-03-15)
|
199
|
+
------------------
|
200
|
+
|
201
|
+
* Feature - Documentation updates for Amazon S3.
|
202
|
+
|
203
|
+
1.144.0 (2024-03-13)
|
204
|
+
------------------
|
205
|
+
|
206
|
+
* Feature - This release makes the default option for S3 on Outposts request signing to use the SigV4A algorithm when using AWS Common Runtime (CRT).
|
207
|
+
|
208
|
+
1.143.1 (2024-03-12)
|
209
|
+
------------------
|
210
|
+
|
211
|
+
* Issue - Include original part errors in message when aborting multipart upload fails (#2990).
|
212
|
+
|
213
|
+
1.143.0 (2024-01-26)
|
214
|
+
------------------
|
215
|
+
|
216
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
217
|
+
|
218
|
+
1.142.0 (2023-12-22)
|
219
|
+
------------------
|
220
|
+
|
221
|
+
* Feature - Added additional examples for some operations.
|
222
|
+
|
223
|
+
1.141.0 (2023-11-28)
|
224
|
+
------------------
|
225
|
+
|
226
|
+
* Feature - Adds support for S3 Express One Zone.
|
227
|
+
|
228
|
+
* Feature - Support S3 Express authentication and endpoints. Express session auth can be disabled with the `disable_s3_express_session_auth` Client option, the `AWS_S3_DISABLE_EXPRESS_SESSION_AUTH` environment variable, and the `s3_disable_express_session_auth` shared config option. A custom `express_credentials_provider` can be configured onto the Client.
|
229
|
+
|
230
|
+
1.140.0 (2023-11-27)
|
231
|
+
------------------
|
232
|
+
|
233
|
+
* Feature - Adding new params - Key and Prefix, to S3 API operations for supporting S3 Access Grants. Note - These updates will not change any of the existing S3 API functionality.
|
234
|
+
|
235
|
+
* Issue - Fix thread interruptions in multipart `download_file`, `file_uploader` and `stream_uploader` (#2944).
|
236
|
+
|
237
|
+
1.139.0 (2023-11-22)
|
238
|
+
------------------
|
239
|
+
|
240
|
+
* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
|
241
|
+
|
242
|
+
1.138.0 (2023-11-21)
|
243
|
+
------------------
|
244
|
+
|
245
|
+
* Feature - Add support for automatic date based partitioning in S3 Server Access Logs.
|
246
|
+
|
247
|
+
1.137.0 (2023-11-17)
|
248
|
+
------------------
|
249
|
+
|
250
|
+
* Feature - Removes all default 0 values for numbers and false values for booleans
|
251
|
+
|
4
252
|
1.136.0 (2023-09-26)
|
5
253
|
------------------
|
6
254
|
|
@@ -46,6 +294,7 @@ Unreleased Changes
|
|
46
294
|
* Feature - S3 Inventory now supports Object Access Control List and Object Owner as available object metadata fields in inventory reports.
|
47
295
|
|
48
296
|
* Feature - Allow Object multipart copy API to work when requiring a checksum algorithm.
|
297
|
+
|
49
298
|
* Feature - Allow Object multipart copy API to optionally copy parts as they exist on the source object if it has parts, instead of generating new part ranges, when specifying `use_source_parts: true`.
|
50
299
|
|
51
300
|
1.129.0 (2023-07-11)
|
@@ -83,7 +332,7 @@ Unreleased Changes
|
|
83
332
|
1.123.2 (2023-06-12)
|
84
333
|
------------------
|
85
334
|
|
86
|
-
* Issue - Fix issue when decrypting noncurrent versions of objects when using client side encryption (#2866).
|
335
|
+
* Issue - Fix issue when decrypting noncurrent versions of objects when using client side encryption (#2866).
|
87
336
|
|
88
337
|
1.123.1 (2023-06-02)
|
89
338
|
------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.176.1
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module S3
|
7
|
+
# @api private
|
8
|
+
class AccessGrantsCredentials
|
9
|
+
include CredentialProvider
|
10
|
+
include RefreshingCredentials
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
@client = options[:client]
|
14
|
+
@get_data_access_params = {}
|
15
|
+
options.each_pair do |key, value|
|
16
|
+
if self.class.get_data_access_options.include?(key)
|
17
|
+
@get_data_access_params[key] = value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@async_refresh = true
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [S3Control::Client]
|
25
|
+
attr_reader :client
|
26
|
+
|
27
|
+
# @return [String]
|
28
|
+
attr_reader :matched_grant_target
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def refresh
|
33
|
+
c = @client.get_data_access(@get_data_access_params)
|
34
|
+
credentials = c.credentials
|
35
|
+
@matched_grant_target = c.matched_grant_target
|
36
|
+
@credentials = Credentials.new(
|
37
|
+
credentials.access_key_id,
|
38
|
+
credentials.secret_access_key,
|
39
|
+
credentials.session_token
|
40
|
+
)
|
41
|
+
@expiration = credentials.expiration
|
42
|
+
end
|
43
|
+
|
44
|
+
class << self
|
45
|
+
|
46
|
+
# @api private
|
47
|
+
def get_data_access_options
|
48
|
+
@gdao ||= begin
|
49
|
+
input = Aws::S3Control::Client.api.operation(:get_data_access).input
|
50
|
+
Set.new(input.shape.member_names)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module S3
|
5
|
+
# @api private
|
6
|
+
def self.access_grants_credentials_cache
|
7
|
+
@access_grants_credentials_cache ||= LRUCache.new(max_entries: 100)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
def self.access_grants_account_id_cache
|
12
|
+
@access_grants_account_id_cache ||= LRUCache.new(
|
13
|
+
max_entries: 100,
|
14
|
+
expiration: 60 * 10
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns Credentials class for S3 Access Grants. Accepts GetDataAccess
|
19
|
+
# params and other configuration as options. See
|
20
|
+
# {Aws::S3Control::Client#get_data_access} for details.
|
21
|
+
class AccessGrantsCredentialsProvider
|
22
|
+
# @param [Hash] options
|
23
|
+
# @option options [Hash] :s3_control_client_options The S3 Control
|
24
|
+
# client options used to create regional S3 Control clients to
|
25
|
+
# create the session. Region will be set to the region of the
|
26
|
+
# bucket.
|
27
|
+
# @option options [Aws::STS::Client] :sts_client The STS client used for
|
28
|
+
# fetching the Account ID for the credentials if credentials do not
|
29
|
+
# include an Account ID.
|
30
|
+
# @option options [Aws::S3::Client] :s3_client The S3 client used for
|
31
|
+
# fetching the location of the bucket so that a regional S3 Control
|
32
|
+
# client can be created. Defaults to the S3 client from the access
|
33
|
+
# grants plugin.
|
34
|
+
# @option options [String] :privilege ('Default') The privilege to use
|
35
|
+
# when requesting credentials. (see: {Aws::S3Control::Client#get_data_access})
|
36
|
+
# @option options [Boolean] :fallback (false) When true, if access is
|
37
|
+
# denied, the provider will fall back to the configured credentials.
|
38
|
+
# @option options [Boolean] :caching (true) When true, credentials and
|
39
|
+
# bucket account ids will be cached.
|
40
|
+
# @option options [Callable] :before_refresh Proc called before
|
41
|
+
# credentials are refreshed.
|
42
|
+
def initialize(options = {})
|
43
|
+
@s3_control_options = options.delete(:s3_control_client_options) || {}
|
44
|
+
@s3_client = options.delete(:s3_client)
|
45
|
+
@sts_client = options.delete(:sts_client)
|
46
|
+
@fallback = options.delete(:fallback) || false
|
47
|
+
@caching = options.delete(:caching) != false
|
48
|
+
@s3_control_clients = {}
|
49
|
+
@bucket_region_cache = Aws::S3.bucket_region_cache
|
50
|
+
@head_bucket_mutex = Mutex.new
|
51
|
+
@head_bucket_call = false
|
52
|
+
return unless @caching
|
53
|
+
|
54
|
+
@credentials_cache = Aws::S3.access_grants_credentials_cache
|
55
|
+
@account_id_cache = Aws::S3.access_grants_account_id_cache
|
56
|
+
end
|
57
|
+
|
58
|
+
def access_grants_credentials_for(options = {})
|
59
|
+
target = target_prefix(
|
60
|
+
options[:bucket],
|
61
|
+
options[:key],
|
62
|
+
options[:prefix]
|
63
|
+
)
|
64
|
+
credentials = s3_client.config.credentials.credentials # resolves
|
65
|
+
|
66
|
+
if @caching
|
67
|
+
cached_credentials_for(target, options[:permission], credentials)
|
68
|
+
else
|
69
|
+
new_credentials_for(target, options[:permission], credentials)
|
70
|
+
end
|
71
|
+
rescue Aws::S3Control::Errors::AccessDenied
|
72
|
+
raise unless @fallback
|
73
|
+
|
74
|
+
warn 'Access denied for S3 Access Grants. Falling back to ' \
|
75
|
+
'configured credentials.'
|
76
|
+
s3_client.config.credentials
|
77
|
+
end
|
78
|
+
|
79
|
+
attr_accessor :s3_client
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def s3_control_client(bucket_region)
|
84
|
+
@s3_control_clients[bucket_region] ||= begin
|
85
|
+
credentials = s3_client.config.credentials
|
86
|
+
config = { credentials: credentials }.merge(@s3_control_options)
|
87
|
+
Aws::S3Control::Client.new(config.merge(
|
88
|
+
region: bucket_region,
|
89
|
+
use_fips_endpoint: s3_client.config.use_fips_endpoint,
|
90
|
+
use_dualstack_endpoint: s3_client.config.use_dualstack_endpoint
|
91
|
+
))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def cached_credentials_for(target, permission, credentials)
|
96
|
+
cached_creds = broad_search_credentials_cache_prefix(target, permission, credentials)
|
97
|
+
return cached_creds if cached_creds
|
98
|
+
|
99
|
+
if %w[READ WRITE].include?(permission)
|
100
|
+
cached_creds = broad_search_credentials_cache_prefix(target, 'READWRITE', credentials)
|
101
|
+
return cached_creds if cached_creds
|
102
|
+
end
|
103
|
+
|
104
|
+
cached_creds = broad_search_credentials_cache_characters(target, permission, credentials)
|
105
|
+
return cached_creds if cached_creds
|
106
|
+
|
107
|
+
if %w[READ WRITE].include?(permission)
|
108
|
+
cached_creds = broad_search_credentials_cache_characters(target, 'READWRITE', credentials)
|
109
|
+
return cached_creds if cached_creds
|
110
|
+
end
|
111
|
+
|
112
|
+
creds = new_credentials_for(target, permission, credentials)
|
113
|
+
if creds.matched_grant_target.end_with?('*')
|
114
|
+
# remove /* from the end of the target
|
115
|
+
key = credentials_cache_key(creds.matched_grant_target[0...-2], permission, credentials)
|
116
|
+
@credentials_cache[key] = creds
|
117
|
+
end
|
118
|
+
|
119
|
+
creds
|
120
|
+
end
|
121
|
+
|
122
|
+
def broad_search_credentials_cache_prefix(target, permission, credentials)
|
123
|
+
prefix = target
|
124
|
+
while prefix != 's3:'
|
125
|
+
key = credentials_cache_key(prefix, permission, credentials)
|
126
|
+
return @credentials_cache[key] if @credentials_cache.key?(key)
|
127
|
+
|
128
|
+
prefix = prefix.split('/', -1)[0..-2].join('/')
|
129
|
+
end
|
130
|
+
nil
|
131
|
+
end
|
132
|
+
|
133
|
+
def broad_search_credentials_cache_characters(target, permission, credentials)
|
134
|
+
prefix = target
|
135
|
+
while prefix != 's3://'
|
136
|
+
key = credentials_cache_key("#{prefix}*", permission, credentials)
|
137
|
+
return @credentials_cache[key] if @credentials_cache.key?(key)
|
138
|
+
|
139
|
+
prefix = prefix[0..-2]
|
140
|
+
end
|
141
|
+
nil
|
142
|
+
end
|
143
|
+
|
144
|
+
def new_credentials_for(target, permission, credentials)
|
145
|
+
bucket_region = bucket_region_for_access_grants(target)
|
146
|
+
client = s3_control_client(bucket_region)
|
147
|
+
|
148
|
+
AccessGrantsCredentials.new(
|
149
|
+
target: target,
|
150
|
+
account_id: account_id_for_access_grants(target, credentials),
|
151
|
+
permission: permission,
|
152
|
+
client: client
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
def account_id_for_access_grants(target, credentials)
|
157
|
+
if @caching
|
158
|
+
cached_account_id_for(target, credentials)
|
159
|
+
else
|
160
|
+
new_account_id_for(target, credentials)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def cached_account_id_for(target, credentials)
|
165
|
+
bucket = bucket_name_from(target)
|
166
|
+
|
167
|
+
if @account_id_cache.key?(bucket)
|
168
|
+
@account_id_cache[bucket]
|
169
|
+
else
|
170
|
+
@account_id_cache[bucket] = new_account_id_for(target, credentials)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# returns the account id associated with the access grants instance
|
175
|
+
def new_account_id_for(target, credentials)
|
176
|
+
bucket_region = bucket_region_for_access_grants(target)
|
177
|
+
s3_control_client = s3_control_client(bucket_region)
|
178
|
+
resp = s3_control_client.get_access_grants_instance_for_prefix(
|
179
|
+
s3_prefix: target,
|
180
|
+
account_id: account_id_for_credentials(bucket_region, credentials)
|
181
|
+
)
|
182
|
+
ARNParser.parse(resp.access_grants_instance_arn).account_id
|
183
|
+
end
|
184
|
+
|
185
|
+
def bucket_region_for_access_grants(target)
|
186
|
+
bucket = bucket_name_from(target)
|
187
|
+
# regardless of caching option, bucket region cache is always shared
|
188
|
+
cached_bucket_region_for(bucket)
|
189
|
+
end
|
190
|
+
|
191
|
+
def cached_bucket_region_for(bucket)
|
192
|
+
if @bucket_region_cache.key?(bucket)
|
193
|
+
@bucket_region_cache[bucket]
|
194
|
+
else
|
195
|
+
@bucket_region_cache[bucket] = new_bucket_region_for(bucket)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def new_bucket_region_for(bucket)
|
200
|
+
@head_bucket_mutex.synchronize do
|
201
|
+
begin
|
202
|
+
@head_bucket_call = true
|
203
|
+
@s3_client.head_bucket(bucket: bucket).bucket_region
|
204
|
+
rescue Aws::S3::Errors::Http301Error => e
|
205
|
+
e.data.region
|
206
|
+
ensure
|
207
|
+
@head_bucket_call = false
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# returns the account id for the configured credentials
|
213
|
+
def account_id_for_credentials(region, credentials)
|
214
|
+
# use resolved credentials to check for account id
|
215
|
+
if credentials.respond_to?(:account_id) && credentials.account_id &&
|
216
|
+
!credentials.account_id.empty?
|
217
|
+
credentials.account_id
|
218
|
+
else
|
219
|
+
@sts_client ||= Aws::STS::Client.new(
|
220
|
+
credentials: s3_client.config.credentials,
|
221
|
+
region: region,
|
222
|
+
use_fips_endpoint: s3_client.config.use_fips_endpoint,
|
223
|
+
use_dualstack_endpoint: s3_client.config.use_dualstack_endpoint
|
224
|
+
)
|
225
|
+
@sts_client.get_caller_identity.account
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def target_prefix(bucket, key, prefix)
|
230
|
+
if key && !key.empty?
|
231
|
+
"s3://#{bucket}/#{key}"
|
232
|
+
elsif prefix && !prefix.empty?
|
233
|
+
"s3://#{bucket}/#{prefix}"
|
234
|
+
else
|
235
|
+
"s3://#{bucket}/*"
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def credentials_cache_key(target, permission, credentials)
|
240
|
+
"#{credentials.access_key_id}-#{credentials.secret_access_key}" \
|
241
|
+
"-#{permission}-#{target}"
|
242
|
+
end
|
243
|
+
|
244
|
+
# extracts bucket name from target prefix
|
245
|
+
def bucket_name_from(target)
|
246
|
+
URI(target).host
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|