aws-sdk-s3 1.156.0 → 1.157.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +12 -3
- data/lib/aws-sdk-s3/client.rb +1 -1
- data/lib/aws-sdk-s3/plugins/access_grants.rb +68 -4
- data/lib/aws-sdk-s3.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a77f1b089e257fe94bc26a0ca7309479a61cff7f46326243f2d1b002ce2bac
|
4
|
+
data.tar.gz: e2dbcc9f6ea92e1097d84130a2cd1c3e1caae305bdeb8b450056872edd2b4f74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34240198a44e4e678e0be7ef836318ff899ec61edc29bc2866d432eb6af834a7f81b801ea85ec35e26deec1e59705c1829b22e66093e6591d84dbc966f76e0e
|
7
|
+
data.tar.gz: 362065ca01c2d4a9e33cc9beb43afce43fbcb8c593db5785a32c623bbc99fe63471a41d767a1ae91343b94aba7df0e80360c0310c1f07aa052c76d63d07fda09
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.157.0
|
@@ -47,6 +47,8 @@ module Aws
|
|
47
47
|
@caching = options.delete(:caching) != false
|
48
48
|
@s3_control_clients = {}
|
49
49
|
@bucket_region_cache = Aws::S3.bucket_region_cache
|
50
|
+
@head_bucket_mutex = Mutex.new
|
51
|
+
@head_bucket_call = false
|
50
52
|
return unless @caching
|
51
53
|
|
52
54
|
@credentials_cache = Aws::S3.access_grants_credentials_cache
|
@@ -195,9 +197,16 @@ module Aws
|
|
195
197
|
end
|
196
198
|
|
197
199
|
def new_bucket_region_for(bucket)
|
198
|
-
@
|
199
|
-
|
200
|
-
|
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
|
201
210
|
end
|
202
211
|
|
203
212
|
# returns the account id for the configured credentials
|
data/lib/aws-sdk-s3/client.rb
CHANGED
@@ -18863,7 +18863,7 @@ module Aws::S3
|
|
18863
18863
|
params: params,
|
18864
18864
|
config: config)
|
18865
18865
|
context[:gem_name] = 'aws-sdk-s3'
|
18866
|
-
context[:gem_version] = '1.
|
18866
|
+
context[:gem_version] = '1.157.0'
|
18867
18867
|
Seahorse::Client::Request.new(handlers, context)
|
18868
18868
|
end
|
18869
18869
|
|
@@ -44,25 +44,47 @@ setting, caching, and fallback behavior.
|
|
44
44
|
list_objects_v2: 'READ',
|
45
45
|
list_object_versions: 'READ',
|
46
46
|
list_parts: 'READ',
|
47
|
+
head_bucket: 'READ',
|
48
|
+
get_object_attributes: 'READ',
|
47
49
|
put_object: 'WRITE',
|
48
50
|
put_object_acl: 'WRITE',
|
49
51
|
delete_object: 'WRITE',
|
50
52
|
abort_multipart_upload: 'WRITE',
|
51
53
|
create_multipart_upload: 'WRITE',
|
52
54
|
upload_part: 'WRITE',
|
53
|
-
complete_multipart_upload: 'WRITE'
|
55
|
+
complete_multipart_upload: 'WRITE',
|
56
|
+
delete_objects: 'WRITE',
|
57
|
+
copy_object: 'READWRITE'
|
54
58
|
}.freeze
|
55
59
|
|
56
60
|
def call(context)
|
61
|
+
provider = context.config.access_grants_credentials_provider
|
62
|
+
|
57
63
|
if access_grants_operation?(context) &&
|
58
|
-
!s3_express_endpoint?(context)
|
64
|
+
!s3_express_endpoint?(context) &&
|
65
|
+
!credentials_head_bucket_call?(provider)
|
59
66
|
params = context[:endpoint_params]
|
60
67
|
permission = PERMISSION_MAP[context.operation_name]
|
61
68
|
|
62
|
-
|
69
|
+
key =
|
70
|
+
case context.operation_name
|
71
|
+
when :delete_objects
|
72
|
+
delete_params = context.params[:delete]
|
73
|
+
common_prefixes(delete_params[:objects].map { |o| o[:key] })
|
74
|
+
when :copy_object
|
75
|
+
source_bucket, source_key = params[:copy_source].split('/', 2)
|
76
|
+
if params[:bucket] != source_bucket
|
77
|
+
raise ArgumentError,
|
78
|
+
'source and destination bucket must be the same'
|
79
|
+
end
|
80
|
+
common_prefixes([params[:key], source_key])
|
81
|
+
else
|
82
|
+
params[:key]
|
83
|
+
end
|
84
|
+
|
63
85
|
credentials = provider.access_grants_credentials_for(
|
64
86
|
bucket: params[:bucket],
|
65
|
-
key:
|
87
|
+
key: key,
|
66
88
|
prefix: params[:prefix],
|
67
89
|
permission: permission
|
68
90
|
)
|
@@ -80,6 +102,12 @@ setting, caching, and fallback behavior.
|
|
80
102
|
Aws::Plugins::UserAgent.metric('S3_ACCESS_GRANTS', &block)
|
81
103
|
end
|
82
104
|
|
105
|
+
# HeadBucket is a supported call. When fetching credentials,
|
106
|
+
# this plugin is executed again, and becomes recursive.
|
107
|
+
def credentials_head_bucket_call?(provider)
|
108
|
+
provider.instance_variable_get(:@head_bucket_call)
|
109
|
+
end
|
110
|
+
|
83
111
|
def access_grants_operation?(context)
|
84
112
|
params = context[:endpoint_params]
|
85
113
|
params[:bucket] && PERMISSION_MAP[context.operation_name]
|
@@ -88,6 +116,42 @@ setting, caching, and fallback behavior.
|
|
88
116
|
def s3_express_endpoint?(context)
|
89
117
|
context[:endpoint_properties]['backend'] == 'S3Express'
|
90
118
|
end
|
119
|
+
|
120
|
+
# Return the common prefix of the keys, regardless of the delimiter.
|
121
|
+
# For example, given keys ['foo/bar', 'foo/baz'], the common prefix
|
122
|
+
# is 'foo/ba'.
|
123
|
+
def common_prefixes(keys)
|
124
|
+
return '' if keys.empty?
|
125
|
+
|
126
|
+
first_key = keys[0]
|
127
|
+
common_ancestor = first_key
|
128
|
+
last_prefix = ''
|
129
|
+
keys.each do |k|
|
130
|
+
until common_ancestor.empty?
|
131
|
+
break if k.start_with?(common_ancestor)
|
132
|
+
|
133
|
+
last_index = common_ancestor.rindex('/')
|
134
|
+
return '' if last_index.nil?
|
135
|
+
|
136
|
+
last_prefix = common_ancestor[(last_index + 1)..-1]
|
137
|
+
common_ancestor = common_ancestor[0...last_index]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
new_common_ancestor = "#{common_ancestor}/#{last_prefix}"
|
141
|
+
keys.each do |k|
|
142
|
+
until last_prefix.empty?
|
143
|
+
break if k.start_with?(new_common_ancestor)
|
144
|
+
|
145
|
+
last_prefix = last_prefix[0...-1]
|
146
|
+
new_common_ancestor = "#{common_ancestor}/#{last_prefix}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
if new_common_ancestor == "#{first_key}/"
|
150
|
+
first_key
|
151
|
+
else
|
152
|
+
new_common_ancestor
|
153
|
+
end
|
154
|
+
end
|
91
155
|
end
|
92
156
|
|
93
157
|
def add_handlers(handlers, config)
|
data/lib/aws-sdk-s3.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.157.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-kms
|