aws-sdk-core 3.232.0 → 3.246.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +126 -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/client_stubs.rb +6 -0
  7. data/lib/aws-sdk-core/credential_provider_chain.rb +71 -22
  8. data/lib/aws-sdk-core/ecs_credentials.rb +25 -15
  9. data/lib/aws-sdk-core/errors.rb +3 -0
  10. data/lib/aws-sdk-core/instance_profile_credentials.rb +21 -11
  11. data/lib/aws-sdk-core/login_credentials.rb +230 -0
  12. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +147 -76
  13. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +28 -16
  14. data/lib/aws-sdk-core/plugins/user_agent.rb +5 -1
  15. data/lib/aws-sdk-core/refreshing_credentials.rb +8 -11
  16. data/lib/aws-sdk-core/shared_config.rb +20 -0
  17. data/lib/aws-sdk-core/sso_credentials.rb +1 -1
  18. data/lib/aws-sdk-core/sso_token_provider.rb +1 -0
  19. data/lib/aws-sdk-core/waiters/poller.rb +2 -2
  20. data/lib/aws-sdk-core.rb +4 -0
  21. data/lib/aws-sdk-signin/client.rb +604 -0
  22. data/lib/aws-sdk-signin/client_api.rb +119 -0
  23. data/lib/aws-sdk-signin/customizations.rb +1 -0
  24. data/lib/aws-sdk-signin/endpoint_parameters.rb +69 -0
  25. data/lib/aws-sdk-signin/endpoint_provider.rb +59 -0
  26. data/lib/aws-sdk-signin/endpoints.rb +20 -0
  27. data/lib/aws-sdk-signin/errors.rb +122 -0
  28. data/lib/aws-sdk-signin/plugins/endpoints.rb +77 -0
  29. data/lib/aws-sdk-signin/resource.rb +26 -0
  30. data/lib/aws-sdk-signin/types.rb +299 -0
  31. data/lib/aws-sdk-signin.rb +63 -0
  32. data/lib/aws-sdk-sso/client.rb +1 -1
  33. data/lib/aws-sdk-sso/endpoint_parameters.rb +4 -4
  34. data/lib/aws-sdk-sso.rb +1 -1
  35. data/lib/aws-sdk-ssooidc/client.rb +20 -7
  36. data/lib/aws-sdk-ssooidc/client_api.rb +5 -0
  37. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +4 -4
  38. data/lib/aws-sdk-ssooidc/errors.rb +10 -0
  39. data/lib/aws-sdk-ssooidc/types.rb +27 -15
  40. data/lib/aws-sdk-ssooidc.rb +1 -1
  41. data/lib/aws-sdk-sts/client.rb +136 -12
  42. data/lib/aws-sdk-sts/client_api.rb +73 -1
  43. data/lib/aws-sdk-sts/customizations.rb +0 -1
  44. data/lib/aws-sdk-sts/endpoint_parameters.rb +5 -5
  45. data/lib/aws-sdk-sts/errors.rb +64 -0
  46. data/lib/aws-sdk-sts/types.rb +175 -6
  47. data/lib/aws-sdk-sts.rb +1 -1
  48. data/lib/seahorse/client/h2/handler.rb +6 -1
  49. data/lib/seahorse/client/net_http/patches.rb +44 -11
  50. metadata +13 -1
@@ -3,10 +3,8 @@
3
3
  module Aws
4
4
  module Plugins
5
5
  module Retries
6
-
7
6
  # @api private
8
7
  class ClockSkew
9
-
10
8
  CLOCK_SKEW_THRESHOLD = 5 * 60 # five minutes
11
9
 
12
10
  def initialize
@@ -22,9 +20,9 @@ module Aws
22
20
  end
23
21
 
24
22
  # Gets the clock_correction in seconds to apply to a given endpoint
25
- # @param endpoint [URI / String]
23
+ # @param endpoint [URI, String]
26
24
  def clock_correction(endpoint)
27
- @mutex.synchronize { @endpoint_clock_corrections[endpoint.to_s] }
25
+ @mutex.synchronize { @endpoint_clock_corrections[normalized_endpoint(endpoint)] }
28
26
  end
29
27
 
30
28
  # The estimated skew factors in any clock skew from
@@ -35,7 +33,7 @@ module Aws
35
33
  # Estimated Skew should not be used to correct clock skew errors
36
34
  # it should only be used to estimate TTL for a request
37
35
  def estimated_skew(endpoint)
38
- @mutex.synchronize { @endpoint_estimated_skews[endpoint.to_s] }
36
+ @mutex.synchronize { @endpoint_estimated_skews[normalized_endpoint(endpoint)] }
39
37
  end
40
38
 
41
39
  # Determines whether a request has clock skew by comparing
@@ -55,9 +53,9 @@ module Aws
55
53
  endpoint = context.http_request.endpoint
56
54
  now_utc = Time.now.utc
57
55
  server_time = server_time(context.http_response)
58
- if server_time && (now_utc - server_time).abs > CLOCK_SKEW_THRESHOLD
59
- set_clock_correction(endpoint, server_time - now_utc)
60
- end
56
+ return unless server_time && (now_utc - server_time).abs > CLOCK_SKEW_THRESHOLD
57
+
58
+ set_clock_correction(normalized_endpoint(endpoint), server_time - now_utc)
61
59
  end
62
60
 
63
61
  # Called for every request
@@ -69,20 +67,35 @@ module Aws
69
67
  now_utc = Time.now.utc
70
68
  server_time = server_time(context.http_response)
71
69
  return unless server_time
70
+
72
71
  @mutex.synchronize do
73
- @endpoint_estimated_skews[endpoint.to_s] = server_time - now_utc
72
+ @endpoint_estimated_skews[normalized_endpoint(endpoint)] = server_time - now_utc
74
73
  end
75
74
  end
76
75
 
77
76
  private
78
77
 
78
+ ##
79
+ # @param endpoint [URI, String]
80
+ # the endpoint to normalize
81
+ #
82
+ # @return [String]
83
+ # the endpoint's schema, host, and port - without any path or query arguments
84
+ def normalized_endpoint(endpoint)
85
+ uri = endpoint.is_a?(URI::Generic) ? endpoint : URI(endpoint.to_s)
86
+
87
+ return endpoint.to_s unless uri.scheme && uri.host
88
+
89
+ "#{uri.scheme}://#{uri.host}:#{uri.port}"
90
+ rescue URI::InvalidURIError
91
+ endpoint.to_s
92
+ end
93
+
79
94
  # @param response [Seahorse::Client::Http::Response:]
80
95
  def server_time(response)
81
- begin
82
- Time.parse(response.headers['date']).utc
83
- rescue
84
- nil
85
- end
96
+ Time.parse(response.headers['date']).utc
97
+ rescue StandardError
98
+ nil
86
99
  end
87
100
 
88
101
  # Sets the clock correction for an endpoint
@@ -90,11 +103,10 @@ module Aws
90
103
  # @param correction [Number]
91
104
  def set_clock_correction(endpoint, correction)
92
105
  @mutex.synchronize do
93
- @endpoint_clock_corrections[endpoint.to_s] = correction
106
+ @endpoint_clock_corrections[normalized_endpoint(endpoint)] = correction
94
107
  end
95
108
  end
96
109
  end
97
110
  end
98
111
  end
99
112
  end
100
-
@@ -55,7 +55,11 @@ 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",
61
+ "S3_TRANSFER_UPLOAD_DIRECTORY": "9",
62
+ "S3_TRANSFER_DOWNLOAD_DIRECTORY": "+"
59
63
  }
60
64
  METRICS
61
65
 
@@ -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
@@ -108,6 +108,7 @@ module Aws
108
108
  cached_token = token_json.dup
109
109
  cached_token['expiresAt'] = cached_token['expiresAt'].iso8601
110
110
  File.write(sso_cache_file, Json.dump(cached_token))
111
+ File.chmod(0o600, sso_cache_file)
111
112
  end
112
113
 
113
114
  def sso_cache_file
@@ -97,8 +97,8 @@ module Aws
97
97
 
98
98
  def matches_error?(acceptor, response)
99
99
  case acceptor['expected']
100
- when 'false' then response.error.nil?
101
- when 'true' then !response.error.nil?
100
+ when 'false', false then response.error.nil?
101
+ when 'true', true then !response.error.nil?
102
102
  else
103
103
  response.error.is_a?(Aws::Errors::ServiceError) &&
104
104
  response.error.code == acceptor['expected'].delete('.')
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'