aws-sdk-core 3.233.0 → 3.234.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f37e6727e5279cbbd03f6df6988d8c24c0eded16e39ec239431e8aed96fbc696
4
- data.tar.gz: 37b13a3e128f56672ed802a5b5450be306d5eeef608222c6cc2dda891356d28d
3
+ metadata.gz: 5c1e5a2e83ce7eed6192c024a73528481a7dc42684ad06ddede22f2fd4e30899
4
+ data.tar.gz: edf282bf751d428d5ef47c2784712b02e2cd6697068a0d31d2030a7eb994f6ab
5
5
  SHA512:
6
- metadata.gz: 7cf0124bf65cf6618b4c14919800bb881920fb6673f34ac6302448dc642c5f7dd051e844904a82e0134c02ab1ea58f1e3b3ccb7d455b9541e09c0c0e45795bae
7
- data.tar.gz: 33d8cb8d286ab0384e2c18d7f43cac14d93147ad3f5b54b6636bea55d4581c2b81cb520c12bab5ea5eceec34ee635d23a04c1038582e2fd69e198636191f66ba
6
+ metadata.gz: 1d497dfce0f982be21901e8273bb9ed40cdf87c291fa7f094f2a593890d4262dc1e3d51db8fd9a0eb5e65681fe6fad4b1bd30f84b4df1c5694d6f2f3f723ca46
7
+ data.tar.gz: '0739213884f5ae50f264cb0a8e94ed7b231397736936c28fa2ac46506f1b2b5204721d0433c8ade2586cb39e3e108c685876f5ff01ae13821f58b014e95d350b'
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.234.0 (2025-10-21)
5
+ ------------------
6
+
7
+ * Issue - Fix `request_checksum_calculation` `when_required` mode to only calculate checksums when explicitly provided by user.
8
+
9
+ * Feature - Add `CREDENTIALS_CODE` metric for `static_profile_` prefixed methods in default credential chain.
10
+
4
11
  3.233.0 (2025-09-23)
5
12
  ------------------
6
13
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.233.0
1
+ 3.234.0
@@ -7,7 +7,7 @@ module Aws
7
7
  # {Aws::STS::Client#assume_role}.
8
8
  #
9
9
  # role_credentials = Aws::AssumeRoleCredentials.new(
10
- # client: Aws::STS::Client.new(...),
10
+ # client: Aws::STS::Client.new(sts_options),
11
11
  # role_arn: "linked::account::arn",
12
12
  # role_session_name: "session-name"
13
13
  # )
@@ -28,15 +28,15 @@ module Aws
28
28
  # @option options [Integer] :duration_seconds
29
29
  # @option options [String] :external_id
30
30
  # @option options [STS::Client] :client
31
- # @option options [Callable] before_refresh Proc called before
31
+ # @option options [Proc] :before_refresh A Proc called before
32
32
  # credentials are refreshed. Useful for updating tokens.
33
- # `before_refresh` is called when AWS credentials are
34
- # required and need to be refreshed. Tokens can be refreshed using
35
- # the following example:
33
+ # `:before_refresh` is called when AWS credentials are
34
+ # required and need to be refreshed. See the example in this doc.
36
35
  #
37
- # before_refresh = Proc.new do |assume_role_credentials| do
38
- # assume_role_credentials.assume_role_params['token_code'] = update_token
39
- # end
36
+ # @example Tokens can be refreshed using a Proc.
37
+ # before_refresh = Proc.new do |assume_role_credentials|
38
+ # assume_role_credentials.assume_role_params['token_code'] = update_token
39
+ # end
40
40
  #
41
41
  def initialize(options = {})
42
42
  client_opts = {}
@@ -9,11 +9,11 @@ module Aws
9
9
  # {Aws::STS::Client#assume_role_with_web_identity}.
10
10
  #
11
11
  # role_credentials = Aws::AssumeRoleWebIdentityCredentials.new(
12
- # client: Aws::STS::Client.new(...),
12
+ # client: Aws::STS::Client.new(sts_options),
13
13
  # role_arn: "linked::account::arn",
14
14
  # web_identity_token_file: "/path/to/token/file",
15
15
  # role_session_name: "session-name"
16
- # ...
16
+ # # ...
17
17
  # )
18
18
  # ec2 = Aws::EC2::Client.new(credentials: role_credentials)
19
19
  #
@@ -11,7 +11,7 @@ module Aws
11
11
  def resolve
12
12
  providers.each do |method_name, options|
13
13
  provider = send(method_name, options.merge(config: @config))
14
- return provider if provider && provider.set?
14
+ return provider if provider&.set?
15
15
  end
16
16
  nil
17
17
  end
@@ -54,47 +54,65 @@ module Aws
54
54
  end
55
55
 
56
56
  def static_profile_assume_role_web_identity_credentials(options)
57
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
58
- Aws.shared_config.assume_role_web_identity_credentials_from_config(
57
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
58
+
59
+ with_metrics('CREDENTIALS_CODE') do
60
+ creds = Aws.shared_config.assume_role_web_identity_credentials_from_config(
59
61
  profile: options[:config].profile,
60
62
  region: options[:config].region
61
63
  )
64
+ return unless creds
65
+
66
+ creds.metrics << 'CREDENTIALS_CODE'
67
+ creds
62
68
  end
63
69
  end
64
70
 
65
71
  def static_profile_sso_credentials(options)
66
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
67
- Aws.shared_config.sso_credentials_from_config(
72
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
73
+
74
+ with_metrics('CREDENTIALS_CODE') do
75
+ creds = Aws.shared_config.sso_credentials_from_config(
68
76
  profile: options[:config].profile
69
77
  )
78
+ return unless creds
79
+
80
+ creds.metrics << 'CREDENTIALS_CODE'
81
+ creds
70
82
  end
71
83
  end
72
84
 
73
85
  def static_profile_assume_role_credentials(options)
74
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
75
- assume_role_with_profile(options, options[:config].profile)
86
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
87
+
88
+ with_metrics('CREDENTIALS_CODE') do
89
+ creds = assume_role_with_profile(options, options[:config].profile)
90
+ return unless creds
91
+
92
+ creds.metrics << 'CREDENTIALS_CODE'
93
+ creds
76
94
  end
77
95
  end
78
96
 
79
97
  def static_profile_credentials(options)
80
- if options[:config] && options[:config].profile
81
- creds = SharedCredentials.new(profile_name: options[:config].profile)
82
- creds.metrics = ['CREDENTIALS_PROFILE']
83
- creds
84
- end
98
+ return unless options[:config]&.profile
99
+
100
+ creds = SharedCredentials.new(profile_name: options[:config].profile)
101
+ creds.metrics << 'CREDENTIALS_PROFILE'
102
+ creds
85
103
  rescue Errors::NoSuchProfileError
86
104
  nil
87
105
  end
88
106
 
89
107
  def static_profile_process_credentials(options)
90
- if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
91
- process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
92
- if process_provider
93
- creds = ProcessCredentials.new([process_provider])
94
- creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
95
- creds
96
- end
97
- end
108
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
109
+
110
+ process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
111
+ return unless process_provider
112
+
113
+ creds = ProcessCredentials.new([process_provider])
114
+ creds.metrics.concat(%w[CREDENTIALS_PROFILE_PROCESS CREDENTIALS_CODE])
115
+ creds
98
116
  rescue Errors::NoSuchProfileError
99
117
  nil
100
118
  end
@@ -122,7 +140,7 @@ module Aws
122
140
  end
123
141
 
124
142
  def determine_profile_name(options)
125
- (options[:config] && options[:config].profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
143
+ (options[:config]&.profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
126
144
  end
127
145
 
128
146
  def shared_credentials(options)
@@ -201,10 +219,14 @@ module Aws
201
219
  profile: profile_name,
202
220
  chain_config: @config
203
221
  }
204
- if options[:config] && options[:config].region
222
+ if options[:config]&.region
205
223
  assume_opts[:region] = options[:config].region
206
224
  end
207
225
  Aws.shared_config.assume_role_credentials_from_config(assume_opts)
208
226
  end
227
+
228
+ def with_metrics(metrics, &block)
229
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
230
+ end
209
231
  end
210
232
  end
@@ -42,26 +42,26 @@ module Aws
42
42
  # @option options [Integer] :retries (5) Number of times to retry
43
43
  # when retrieving credentials.
44
44
  # @option options [String] :ip_address ('169.254.170.2') This value is
45
- # ignored if `endpoint` is set and `credential_path` is not set.
46
- # @option options [Integer] :port (80) This value is ignored if `endpoint`
47
- # is set and `credential_path` is not set.
45
+ # ignored if `:endpoint` is set and `:credential_path` is not set.
46
+ # @option options [Integer] :port (80) This value is ignored if `:endpoint`
47
+ # is set and `:credential_path` is not set.
48
48
  # @option options [String] :credential_path By default, the value of the
49
- # AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable.
49
+ # `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` environment variable.
50
50
  # @option options [String] :endpoint The container credential endpoint.
51
- # By default, this is the value of the AWS_CONTAINER_CREDENTIALS_FULL_URI
52
- # environment variable. This value is ignored if `credential_path` or
53
- # ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] is set.
51
+ # By default, this is the value of the `AWS_CONTAINER_CREDENTIALS_FULL_URI`
52
+ # environment variable. This value is ignored if `:credential_path` or
53
+ # `ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']` is set.
54
54
  # @option options [Float] :http_open_timeout (5)
55
55
  # @option options [Float] :http_read_timeout (5)
56
- # @option options [Numeric, Proc] :delay By default, failures are retried
56
+ # @option options [IO] :http_debug_output (nil) HTTP wire
57
+ # traces are sent to this object. You can specify something
58
+ # like `$stdout`.
59
+ # @option options [Numeric, Proc] :backoff By default, failures are retried
57
60
  # with exponential back-off, i.e. `sleep(1.2 ** num_failures)`. You can
58
61
  # pass a number of seconds to sleep between failed attempts, or
59
62
  # a Proc that accepts the number of failures.
60
- # @option options [IO] :http_debug_output (nil) HTTP wire
61
- # traces are sent to this object. You can specify something
62
- # like $stdout.
63
- # @option options [Callable] before_refresh Proc called before
64
- # credentials are refreshed. `before_refresh` is called
63
+ # @option options [Proc] :before_refresh A Proc called before
64
+ # credentials are refreshed. `:before_refresh` is called
65
65
  # with an instance of this object when
66
66
  # AWS credentials are required and need to be refreshed.
67
67
  def initialize(options = {})
@@ -190,7 +190,6 @@ module Aws
190
190
  name: "x-amz-checksum-#{algorithm.downcase}",
191
191
  request_algorithm_header: request_algorithm_header(context)
192
192
  }
193
-
194
193
  context[:http_checksum][:request_algorithm] = request_algorithm
195
194
  calculate_request_checksum(context, request_algorithm)
196
195
  end
@@ -249,6 +248,7 @@ module Aws
249
248
  return unless context.operation.http_checksum
250
249
 
251
250
  input_member = context.operation.http_checksum['requestAlgorithmMember']
251
+
252
252
  context.params[input_member.to_sym] ||= DEFAULT_CHECKSUM if input_member
253
253
  end
254
254
 
@@ -271,25 +271,39 @@ module Aws
271
271
  context.operation.http_checksum['responseAlgorithms']
272
272
  end
273
273
 
274
- def checksum_required?(context)
275
- (http_checksum = context.operation.http_checksum) &&
276
- (checksum_required = http_checksum['requestChecksumRequired']) &&
277
- (checksum_required && context.config.request_checksum_calculation == 'when_required')
278
- end
279
-
280
- def checksum_optional?(context)
281
- context.operation.http_checksum &&
282
- context.config.request_checksum_calculation != 'when_required'
283
- end
284
-
285
274
  def checksum_provided_as_header?(headers)
286
275
  headers.any? { |k, _| k.start_with?('x-amz-checksum-') }
287
276
  end
288
277
 
278
+ # Determines whether a request checksum should be calculated.
279
+ # 1. **No existing checksum in header**: Skips if checksum header already present
280
+ # 2. **Operation support**: Considers model, client configuration and user input.
289
281
  def should_calculate_request_checksum?(context)
290
282
  !checksum_provided_as_header?(context.http_request.headers) &&
291
- request_algorithm_selection(context) &&
292
- (checksum_required?(context) || checksum_optional?(context))
283
+ checksum_applicable?(context)
284
+ end
285
+
286
+ # Checks if checksum calculation should proceed based on operation requirements and client settings.
287
+ # Returns true when any of these conditions are met:
288
+ # 1. http checksum's requestChecksumRequired is true
289
+ # 2. Config for request_checksum_calculation is "when_supported"
290
+ # 3. Config for request_checksum_calculation is "when_required" AND user provided checksum algorithm
291
+ def checksum_applicable?(context)
292
+ http_checksum = context.operation.http_checksum
293
+ return false unless http_checksum
294
+
295
+ return true if http_checksum['requestChecksumRequired']
296
+
297
+ return false unless (algorithm_member = http_checksum['requestAlgorithmMember'])
298
+
299
+ case context.config.request_checksum_calculation
300
+ when 'when_supported'
301
+ true
302
+ when 'when_required'
303
+ !context.params[algorithm_member.to_sym].nil?
304
+ else
305
+ false
306
+ end
293
307
  end
294
308
 
295
309
  def choose_request_algorithm!(context)
@@ -1,28 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aws
4
-
5
4
  # Base class used credential classes that can be refreshed. This
6
5
  # provides basic refresh logic in a thread-safe manner. Classes mixing in
7
- # this module are expected to implement a #refresh method that populates
6
+ # this module are expected to implement a `#refresh` method that populates
8
7
  # the following instance variables:
9
8
  #
10
- # * `@access_key_id`
11
- # * `@secret_access_key`
12
- # * `@session_token`
13
- # * `@expiration`
9
+ # * `@credentials` ({Credentials})
10
+ # * `@expiration` (Time)
14
11
  #
15
- # @api private
16
12
  module RefreshingCredentials
17
-
18
13
  SYNC_EXPIRATION_LENGTH = 300 # 5 minutes
19
14
  ASYNC_EXPIRATION_LENGTH = 600 # 10 minutes
20
15
 
21
16
  CLIENT_EXCLUDE_OPTIONS = Set.new([:before_refresh]).freeze
22
17
 
18
+ # @param [Hash] options
19
+ # @option options [Proc] :before_refresh A Proc called before credentials are refreshed.
20
+ # It accepts `self` as the only argument.
23
21
  def initialize(options = {})
24
22
  @mutex = Mutex.new
25
- @before_refresh = options.delete(:before_refresh) if Hash === options
23
+ @before_refresh = options.delete(:before_refresh) if options.is_a?(Hash)
26
24
 
27
25
  @before_refresh.call(self) if @before_refresh
28
26
  refresh
@@ -59,7 +57,7 @@ module Aws
59
57
  # Otherwise, if we're approaching expiration, use the existing credentials
60
58
  # but attempt a refresh in the background.
61
59
  def refresh_if_near_expiration!
62
- # Note: This check is an optimization. Rather than acquire the mutex on every #refresh_if_near_expiration
60
+ # NOTE: This check is an optimization. Rather than acquire the mutex on every #refresh_if_near_expiration
63
61
  # call, we check before doing so, and then we check within the mutex to avoid a race condition.
64
62
  # See issue: https://github.com/aws/aws-sdk-ruby/issues/2641 for more info.
65
63
  if near_expiration?(sync_expiration_length)
@@ -91,6 +89,5 @@ module Aws
91
89
  true
92
90
  end
93
91
  end
94
-
95
92
  end
96
93
  end
@@ -7,7 +7,7 @@ module Aws
7
7
  # {Aws::SSOTokenProvider} will be used to refresh the token if possible.
8
8
  # This class does NOT implement the SSO login token flow - tokens
9
9
  # must generated separately by running `aws login` from the
10
- # AWS CLI with the correct profile. The `SSOCredentials` will
10
+ # AWS CLI with the correct profile. The {SSOCredentials} will
11
11
  # auto-refresh the AWS credentials from SSO.
12
12
  #
13
13
  # # You must first run aws sso login --profile your-sso-profile
@@ -698,7 +698,7 @@ module Aws::SSO
698
698
  tracer: tracer
699
699
  )
700
700
  context[:gem_name] = 'aws-sdk-core'
701
- context[:gem_version] = '3.233.0'
701
+ context[:gem_version] = '3.234.0'
702
702
  Seahorse::Client::Request.new(handlers, context)
703
703
  end
704
704
 
data/lib/aws-sdk-sso.rb CHANGED
@@ -56,7 +56,7 @@ module Aws::SSO
56
56
  autoload :EndpointProvider, 'aws-sdk-sso/endpoint_provider'
57
57
  autoload :Endpoints, 'aws-sdk-sso/endpoints'
58
58
 
59
- GEM_VERSION = '3.233.0'
59
+ GEM_VERSION = '3.234.0'
60
60
 
61
61
  end
62
62
 
@@ -1081,7 +1081,7 @@ module Aws::SSOOIDC
1081
1081
  tracer: tracer
1082
1082
  )
1083
1083
  context[:gem_name] = 'aws-sdk-core'
1084
- context[:gem_version] = '3.233.0'
1084
+ context[:gem_version] = '3.234.0'
1085
1085
  Seahorse::Client::Request.new(handlers, context)
1086
1086
  end
1087
1087
 
@@ -56,7 +56,7 @@ module Aws::SSOOIDC
56
56
  autoload :EndpointProvider, 'aws-sdk-ssooidc/endpoint_provider'
57
57
  autoload :Endpoints, 'aws-sdk-ssooidc/endpoints'
58
58
 
59
- GEM_VERSION = '3.233.0'
59
+ GEM_VERSION = '3.234.0'
60
60
 
61
61
  end
62
62
 
@@ -2601,7 +2601,7 @@ module Aws::STS
2601
2601
  tracer: tracer
2602
2602
  )
2603
2603
  context[:gem_name] = 'aws-sdk-core'
2604
- context[:gem_version] = '3.233.0'
2604
+ context[:gem_version] = '3.234.0'
2605
2605
  Seahorse::Client::Request.new(handlers, context)
2606
2606
  end
2607
2607
 
data/lib/aws-sdk-sts.rb CHANGED
@@ -56,7 +56,7 @@ module Aws::STS
56
56
  autoload :EndpointProvider, 'aws-sdk-sts/endpoint_provider'
57
57
  autoload :Endpoints, 'aws-sdk-sts/endpoints'
58
58
 
59
- GEM_VERSION = '3.233.0'
59
+ GEM_VERSION = '3.234.0'
60
60
 
61
61
  end
62
62
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.233.0
4
+ version: 3.234.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services