aws-sdk-core 3.233.0 → 3.239.2

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +58 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/assume_role_credentials.rb +8 -8
  5. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +2 -2
  6. data/lib/aws-sdk-core/credential_provider_chain.rb +71 -22
  7. data/lib/aws-sdk-core/ecs_credentials.rb +13 -13
  8. data/lib/aws-sdk-core/errors.rb +3 -0
  9. data/lib/aws-sdk-core/instance_profile_credentials.rb +7 -7
  10. data/lib/aws-sdk-core/login_credentials.rb +229 -0
  11. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +28 -14
  12. data/lib/aws-sdk-core/plugins/user_agent.rb +3 -1
  13. data/lib/aws-sdk-core/refreshing_credentials.rb +8 -11
  14. data/lib/aws-sdk-core/shared_config.rb +20 -0
  15. data/lib/aws-sdk-core/sso_credentials.rb +1 -1
  16. data/lib/aws-sdk-core.rb +4 -0
  17. data/lib/aws-sdk-signin/client.rb +604 -0
  18. data/lib/aws-sdk-signin/client_api.rb +119 -0
  19. data/lib/aws-sdk-signin/customizations.rb +1 -0
  20. data/lib/aws-sdk-signin/endpoint_parameters.rb +69 -0
  21. data/lib/aws-sdk-signin/endpoint_provider.rb +59 -0
  22. data/lib/aws-sdk-signin/endpoints.rb +20 -0
  23. data/lib/aws-sdk-signin/errors.rb +122 -0
  24. data/lib/aws-sdk-signin/plugins/endpoints.rb +77 -0
  25. data/lib/aws-sdk-signin/resource.rb +26 -0
  26. data/lib/aws-sdk-signin/types.rb +299 -0
  27. data/lib/aws-sdk-signin.rb +63 -0
  28. data/lib/aws-sdk-sso/client.rb +1 -1
  29. data/lib/aws-sdk-sso/endpoint_parameters.rb +4 -4
  30. data/lib/aws-sdk-sso.rb +1 -1
  31. data/lib/aws-sdk-ssooidc/client.rb +1 -1
  32. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +4 -4
  33. data/lib/aws-sdk-ssooidc.rb +1 -1
  34. data/lib/aws-sdk-sts/client.rb +136 -12
  35. data/lib/aws-sdk-sts/client_api.rb +72 -0
  36. data/lib/aws-sdk-sts/endpoint_parameters.rb +5 -5
  37. data/lib/aws-sdk-sts/errors.rb +64 -0
  38. data/lib/aws-sdk-sts/types.rb +175 -6
  39. data/lib/aws-sdk-sts.rb +1 -1
  40. data/lib/seahorse/client/h2/handler.rb +6 -1
  41. metadata +13 -1
@@ -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)
@@ -55,7 +55,9 @@ module Aws
55
55
  "CREDENTIALS_IMDS" : "0",
56
56
  "SSO_LOGIN_DEVICE" : "1",
57
57
  "SSO_LOGIN_AUTH" : "2",
58
- "BEARER_SERVICE_ENV_VARS": "3"
58
+ "BEARER_SERVICE_ENV_VARS": "3",
59
+ "CREDENTIALS_PROFILE_LOGIN": "AC",
60
+ "CREDENTIALS_LOGIN": "AD"
59
61
  }
60
62
  METRICS
61
63
 
@@ -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
@@ -171,6 +171,16 @@ module Aws
171
171
  token
172
172
  end
173
173
 
174
+ # Attempts to load from shared config or shared credentials file.
175
+ # Will always attempt first to load from the shared credentials
176
+ # file, if present.
177
+ def login_credentials_from_config(opts = {})
178
+ p = opts[:profile] || @profile_name
179
+ credentials = login_credentials_from_profile(@parsed_credentials, p, opts[:region])
180
+ credentials ||= login_credentials_from_profile(@parsed_config, p, opts[:region]) if @parsed_config
181
+ credentials
182
+ end
183
+
174
184
  # Source a custom configured endpoint from the shared configuration file
175
185
  #
176
186
  # @param [Hash] opts
@@ -469,6 +479,16 @@ module Aws
469
479
  end
470
480
  end
471
481
 
482
+ def login_credentials_from_profile(cfg, profile, region)
483
+ return unless @parsed_config && (prof_config = cfg[profile]) && prof_config['login_session']
484
+
485
+ cfg = { login_session: prof_config['login_session'] }
486
+ cfg[:region] = region if region
487
+ creds = LoginCredentials.new(cfg)
488
+ creds.metrics << 'CREDENTIALS_PROFILE_LOGIN'
489
+ creds
490
+ end
491
+
472
492
  def credentials_from_profile(prof_config)
473
493
  creds = Credentials.new(
474
494
  prof_config['aws_access_key_id'],
@@ -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
data/lib/aws-sdk-core.rb CHANGED
@@ -25,6 +25,7 @@ module Aws
25
25
  autoload :SharedCredentials, 'aws-sdk-core/shared_credentials'
26
26
  autoload :ProcessCredentials, 'aws-sdk-core/process_credentials'
27
27
  autoload :SSOCredentials, 'aws-sdk-core/sso_credentials'
28
+ autoload :LoginCredentials, 'aws-sdk-core/login_credentials'
28
29
 
29
30
 
30
31
  # tokens and token providers
@@ -175,3 +176,6 @@ require_relative 'aws-sdk-sts'
175
176
  # aws-sdk-sso is included to support Aws::SSOCredentials
176
177
  require_relative 'aws-sdk-sso'
177
178
  require_relative 'aws-sdk-ssooidc'
179
+
180
+ # aws-sdk-signin is included to support Aws::SignInCredentials
181
+ require_relative 'aws-sdk-signin'