aws-sdk-core 3.224.1 → 3.240.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +157 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +2 -1
  5. data/lib/aws-sdk-core/assume_role_credentials.rb +8 -8
  6. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +2 -2
  7. data/lib/aws-sdk-core/client_stubs.rb +6 -0
  8. data/lib/aws-sdk-core/credential_provider_chain.rb +72 -23
  9. data/lib/aws-sdk-core/ecs_credentials.rb +13 -13
  10. data/lib/aws-sdk-core/endpoints/matchers.rb +2 -1
  11. data/lib/aws-sdk-core/endpoints.rb +37 -13
  12. data/lib/aws-sdk-core/error_handler.rb +5 -0
  13. data/lib/aws-sdk-core/errors.rb +3 -0
  14. data/lib/aws-sdk-core/event_emitter.rb +1 -1
  15. data/lib/aws-sdk-core/instance_profile_credentials.rb +146 -157
  16. data/lib/aws-sdk-core/json/error_handler.rb +14 -4
  17. data/lib/aws-sdk-core/login_credentials.rb +229 -0
  18. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +28 -14
  19. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +75 -59
  20. data/lib/aws-sdk-core/plugins/sign.rb +23 -28
  21. data/lib/aws-sdk-core/plugins/stub_responses.rb +6 -0
  22. data/lib/aws-sdk-core/plugins/user_agent.rb +4 -1
  23. data/lib/aws-sdk-core/refreshing_credentials.rb +8 -11
  24. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +26 -16
  25. data/lib/aws-sdk-core/rpc_v2/parser.rb +8 -0
  26. data/lib/aws-sdk-core/shared_config.rb +30 -0
  27. data/lib/aws-sdk-core/sso_credentials.rb +1 -1
  28. data/lib/aws-sdk-core/static_token_provider.rb +1 -2
  29. data/lib/aws-sdk-core/token.rb +3 -3
  30. data/lib/aws-sdk-core/token_provider.rb +4 -0
  31. data/lib/aws-sdk-core/token_provider_chain.rb +2 -6
  32. data/lib/aws-sdk-core/util.rb +2 -1
  33. data/lib/aws-sdk-core/xml/error_handler.rb +3 -1
  34. data/lib/aws-sdk-core.rb +4 -0
  35. data/lib/aws-sdk-signin/client.rb +604 -0
  36. data/lib/aws-sdk-signin/client_api.rb +119 -0
  37. data/lib/aws-sdk-signin/customizations.rb +1 -0
  38. data/lib/aws-sdk-signin/endpoint_parameters.rb +69 -0
  39. data/lib/aws-sdk-signin/endpoint_provider.rb +59 -0
  40. data/lib/aws-sdk-signin/endpoints.rb +20 -0
  41. data/lib/aws-sdk-signin/errors.rb +122 -0
  42. data/lib/aws-sdk-signin/plugins/endpoints.rb +77 -0
  43. data/lib/aws-sdk-signin/resource.rb +26 -0
  44. data/lib/aws-sdk-signin/types.rb +299 -0
  45. data/lib/aws-sdk-signin.rb +63 -0
  46. data/lib/aws-sdk-sso/client.rb +24 -17
  47. data/lib/aws-sdk-sso/endpoint_parameters.rb +4 -4
  48. data/lib/aws-sdk-sso/endpoint_provider.rb +2 -2
  49. data/lib/aws-sdk-sso.rb +1 -1
  50. data/lib/aws-sdk-ssooidc/client.rb +43 -23
  51. data/lib/aws-sdk-ssooidc/client_api.rb +5 -0
  52. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +4 -4
  53. data/lib/aws-sdk-ssooidc/errors.rb +10 -0
  54. data/lib/aws-sdk-ssooidc/types.rb +27 -15
  55. data/lib/aws-sdk-ssooidc.rb +1 -1
  56. data/lib/aws-sdk-sts/client.rb +159 -28
  57. data/lib/aws-sdk-sts/client_api.rb +74 -0
  58. data/lib/aws-sdk-sts/customizations.rb +0 -1
  59. data/lib/aws-sdk-sts/endpoint_parameters.rb +5 -5
  60. data/lib/aws-sdk-sts/errors.rb +64 -1
  61. data/lib/aws-sdk-sts/presigner.rb +2 -6
  62. data/lib/aws-sdk-sts/types.rb +175 -6
  63. data/lib/aws-sdk-sts.rb +1 -1
  64. data/lib/seahorse/client/h2/handler.rb +6 -1
  65. data/lib/seahorse/client/net_http/connection_pool.rb +2 -1
  66. data/lib/seahorse/client/request_context.rb +2 -2
  67. data/lib/seahorse/util.rb +2 -1
  68. metadata +28 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0504743f3e3a403f83f5ee206527bedd7e65670b2398299eb608e9808694ced
4
- data.tar.gz: 4fd94bb6f4e7f33f2b7e81b77e09fede47ef0385aab7002448dadbe2b569c91e
3
+ metadata.gz: bfea66796a6586854e469946701deeb09f2b344e82967f505262052efea4c972
4
+ data.tar.gz: 98d0d7a3da929b82b7b14098d0041532d94ec0f88bfa04e74c5bcf8286e090b3
5
5
  SHA512:
6
- metadata.gz: b746c5749870287501ea3d1d0cdf968913d3c95331c520f62518a2bf17a7caa21c9c2454098feb42fba3f38d5db11f5e7835076f8b81c47dd284d4b428c447bb
7
- data.tar.gz: 95695ed0514d2ed18fd9c9acdd14c975118fb2e3fced14f4c96274e357b7da3f59400e5ea8872bec9d1faba89212e638cd08178dfff3b2e27b9fda0ef9be8e69
6
+ metadata.gz: 65092f9f2795f01ee929393ccdbb06ca55d2e0ea420ac7004c0d24fe6bfd9e3b155cd2d4869b96a6deb64e65c8d4fd0e917e8834ea0cac3602a9289df6de4c4f
7
+ data.tar.gz: 806b5e412f3a25b956d607f948e957e71241b25fdea11306d43a9752570d5daa80e33740c543bc499d74412d63db8325c9c9bf39ae4738c971e318ac33503b47
data/CHANGELOG.md CHANGED
@@ -1,6 +1,163 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.240.0 (2025-12-16)
5
+ ------------------
6
+
7
+ * Feature - Updated configuration values for `defaults_mode`.
8
+
9
+ * Issue - Prioritizes JSON over CBOR when both are supported for stubbed clients.
10
+
11
+ 3.239.2 (2025-11-25)
12
+ ------------------
13
+
14
+ * Issue - Fix `login_credentials` in credentials chain when config is enabled.
15
+
16
+ 3.239.1 (2025-11-21)
17
+ ------------------
18
+
19
+ * Issue - Fixed HTTP/2 connection issues when using custom ports.
20
+
21
+ 3.239.0 (2025-11-20)
22
+ ------------------
23
+
24
+ * Feature - Updated Aws::Signin::Client with the latest API changes.
25
+
26
+ * Issue - Fix region configuration for LoginCredential's Signin client.
27
+
28
+ 3.238.0 (2025-11-19)
29
+ ------------------
30
+
31
+ * Feature - Updated Aws::Signin::Client with the latest API changes.
32
+
33
+ * Feature - Updated Aws::STS::Client with the latest API changes.
34
+
35
+ * Feature - IAM now supports outbound identity federation via the STS GetWebIdentityToken API, enabling AWS workloads to securely authenticate with external services using short-lived JSON Web Tokens.
36
+
37
+ * Feature - Add `LoginCredentials` which retrieves credentials from AWS Sign-In. Support `aws-sdk-signin` alias gem.
38
+
39
+ 3.237.0 (2025-11-10)
40
+ ------------------
41
+
42
+ * Feature - Updated Aws::STS::Client with the latest API changes.
43
+
44
+ * Feature - Added GetDelegatedAccessToken API, which is not available for general use at this time.
45
+
46
+ 3.236.0 (2025-10-30)
47
+ ------------------
48
+
49
+ * Feature - Updated Aws::STS::Client with the latest API changes.
50
+
51
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
52
+
53
+ * Feature - Update endpoint ruleset parameters casing
54
+
55
+ 3.235.0 (2025-10-24)
56
+ ------------------
57
+
58
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
59
+
60
+ * Feature - Update endpoint ruleset parameters casing
61
+
62
+ 3.234.0 (2025-10-21)
63
+ ------------------
64
+
65
+ * Issue - Fix `request_checksum_calculation` `when_required` mode to only calculate checksums when explicitly provided by user.
66
+
67
+ * Feature - Add `CREDENTIALS_CODE` metric for `static_profile_` prefixed methods in default credential chain.
68
+
69
+ 3.233.0 (2025-09-23)
70
+ ------------------
71
+
72
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
73
+
74
+ * Feature - This release includes exception definition and documentation updates.
75
+
76
+ 3.232.0 (2025-08-28)
77
+ ------------------
78
+
79
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
80
+
81
+ * Feature - Remove incorrect endpoint tests
82
+
83
+ 3.231.0 (2025-08-26)
84
+ ------------------
85
+
86
+ * Feature - Remove incorrect endpoint tests
87
+
88
+ * Feature - Add support for ENV as credential source for `AssumeRoleCredentials`.
89
+
90
+ 3.230.0 (2025-08-21)
91
+ ------------------
92
+
93
+ * Feature - Remove incorrect endpoint tests
94
+
95
+ 3.229.0 (2025-08-04)
96
+ ------------------
97
+
98
+ * Feature - Updated Aws::STS::Client with the latest API changes.
99
+
100
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
101
+
102
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
103
+
104
+ 3.228.0 (2025-07-31)
105
+ ------------------
106
+
107
+ * Feature - Add `bigdecimal` as a dependency. For systems that are not able to build native extension gems, prefer the locally installed `bigdecimal` with `bundle install --prefer-local`.
108
+
109
+ 3.227.0 (2025-07-21)
110
+ ------------------
111
+
112
+ * Feature - Updated Aws::STS::Client with the latest API changes.
113
+
114
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
115
+
116
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
117
+
118
+ * Feature - Support an auth scheme signing preference list using `ENV['AWS_AUTH_SCHEME_PREFERENCE']` or `auth_scheme_preference` in shared configuration.
119
+
120
+ * Feature - Support metric tracking for Bedrock Bearer tokens.
121
+
122
+ 3.226.3 (2025-07-17)
123
+ ------------------
124
+
125
+ * Issue - Skip `Aws::InstanceProfileCredentials` instantiation when `ENV['AWS_EC2_METADATA_DISABLED']` is set to `true` in the credential resolution chain.
126
+
127
+ * Issue - Refactor `InstanceProfileCredentials` to improve code clarity and documentation.
128
+
129
+ 3.226.2 (2025-07-01)
130
+ ------------------
131
+
132
+ * Issue - Document incorrect behavior in protocol error parsing (specifically around query and query compatible services).
133
+
134
+ 3.226.1 (2025-06-24)
135
+ ------------------
136
+
137
+ * Issue - Fixed spelling in the `Aws::Errors::SignalEventError` error message.
138
+
139
+ 3.226.0 (2025-06-17)
140
+ ------------------
141
+
142
+ * Feature - Updated Aws::STS::Client with the latest API changes.
143
+
144
+ * Feature - The AWS Security Token Service APIs AssumeRoleWithSAML and AssumeRoleWithWebIdentity can now be invoked without pre-configured AWS credentials in the SDK configuration.
145
+
146
+ 3.225.2 (2025-06-10)
147
+ ------------------
148
+
149
+ * Issue - Only load required `cgi` modules for Ruby 3.5.
150
+
151
+ 3.225.1 (2025-06-05)
152
+ ------------------
153
+
154
+ * Issue - Fix RPCv2 parser to handle flattened list and flattened map members correctly for `AwsQueryCompatible` services.
155
+
156
+ 3.225.0 (2025-06-02)
157
+ ------------------
158
+
159
+ * Feature - AWS SDK for Ruby no longer supports Ruby runtime versions 2.5 and 2.6.
160
+
4
161
  3.224.1 (2025-05-28)
5
162
  ------------------
6
163
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.224.1
1
+ 3.240.0
@@ -128,7 +128,8 @@ module Aws
128
128
  "override" => 3100
129
129
  }
130
130
  },
131
- "in-region" => {},
131
+ "in-region" => {
132
+ },
132
133
  "cross-region" => {
133
134
  "connectTimeoutInMillis" => {
134
135
  "override" => 3100
@@ -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
  #
@@ -280,6 +280,12 @@ module Aws
280
280
  end
281
281
 
282
282
  def protocol_helper
283
+ # Prioritize JSON over CBOR when CBOR is the configured protocol but both are supported. This is to match similar
284
+ # prioritization in service.rb code generation.
285
+ if @config.api.metadata['protocol'] == 'smithy-rpc-v2-cbor' && @config.api.metadata['protocols']&.include?('json')
286
+ return Stubbing::Protocols::Json.new
287
+ end
288
+
283
289
  case @config.api.metadata['protocol']
284
290
  when 'json' then Stubbing::Protocols::Json
285
291
  when 'rest-json' then Stubbing::Protocols::RestJson
@@ -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
@@ -25,12 +25,14 @@ module Aws
25
25
  [:static_profile_sso_credentials, {}],
26
26
  [:static_profile_assume_role_credentials, {}],
27
27
  [:static_profile_credentials, {}],
28
+ [:static_profile_login_credentials, {}],
28
29
  [:static_profile_process_credentials, {}],
29
30
  [:env_credentials, {}],
30
31
  [:assume_role_web_identity_credentials, {}],
31
32
  [:sso_credentials, {}],
32
33
  [:assume_role_credentials, {}],
33
34
  [:shared_credentials, {}],
35
+ [:login_credentials, {}],
34
36
  [:process_credentials, {}],
35
37
  [:instance_profile_credentials, {
36
38
  retries: @config ? @config.instance_profile_credentials_retries : 0,
@@ -54,47 +56,80 @@ module Aws
54
56
  end
55
57
 
56
58
  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(
59
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
60
+
61
+ with_metrics('CREDENTIALS_CODE') do
62
+ creds = Aws.shared_config.assume_role_web_identity_credentials_from_config(
59
63
  profile: options[:config].profile,
60
64
  region: options[:config].region
61
65
  )
66
+ return unless creds
67
+
68
+ creds.metrics << 'CREDENTIALS_CODE'
69
+ creds
62
70
  end
63
71
  end
64
72
 
65
73
  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(
74
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
75
+
76
+ with_metrics('CREDENTIALS_CODE') do
77
+ creds = Aws.shared_config.sso_credentials_from_config(
68
78
  profile: options[:config].profile
69
79
  )
80
+ return unless creds
81
+
82
+ creds.metrics << 'CREDENTIALS_CODE'
83
+ creds
70
84
  end
71
85
  end
72
86
 
73
87
  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)
88
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
89
+
90
+ with_metrics('CREDENTIALS_CODE') do
91
+ creds = assume_role_with_profile(options, options[:config].profile)
92
+ return unless creds
93
+
94
+ creds.metrics << 'CREDENTIALS_CODE'
95
+ creds
76
96
  end
77
97
  end
78
98
 
79
99
  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
100
+ return unless options[:config]&.profile
101
+
102
+ creds = SharedCredentials.new(profile_name: options[:config].profile)
103
+ creds.metrics << 'CREDENTIALS_PROFILE'
104
+ creds
85
105
  rescue Errors::NoSuchProfileError
86
106
  nil
87
107
  end
88
108
 
89
- 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
109
+ def static_profile_login_credentials(options)
110
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
111
+
112
+ with_metrics('CREDENTIALS_CODE') do
113
+ creds = Aws.shared_config.login_credentials_from_config(
114
+ profile: options[:config].profile,
115
+ region: options[:config].region
116
+ )
117
+ return unless creds
118
+
119
+ creds.metrics << 'CREDENTIALS_CODE'
120
+ creds
97
121
  end
122
+ end
123
+
124
+ def static_profile_process_credentials(options)
125
+ return unless Aws.shared_config.config_enabled? && options[:config]&.profile
126
+
127
+ process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
128
+ return unless process_provider
129
+
130
+ creds = ProcessCredentials.new([process_provider])
131
+ creds.metrics.concat(%w[CREDENTIALS_PROFILE_PROCESS CREDENTIALS_CODE])
132
+ creds
98
133
  rescue Errors::NoSuchProfileError
99
134
  nil
100
135
  end
@@ -122,7 +157,7 @@ module Aws
122
157
  end
123
158
 
124
159
  def determine_profile_name(options)
125
- (options[:config] && options[:config].profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
160
+ (options[:config]&.profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
126
161
  end
127
162
 
128
163
  def shared_credentials(options)
@@ -134,6 +169,16 @@ module Aws
134
169
  nil
135
170
  end
136
171
 
172
+ def login_credentials(options)
173
+ return unless Aws.shared_config.config_enabled?
174
+
175
+ profile_name = determine_profile_name(options)
176
+ region = options[:config].region if options[:config]
177
+ Aws.shared_config.login_credentials_from_config(profile: profile_name, region: region)
178
+ rescue Errors::NoSuchProfileError
179
+ nil
180
+ end
181
+
137
182
  def process_credentials(options)
138
183
  profile_name = determine_profile_name(options)
139
184
  if Aws.shared_config.config_enabled?
@@ -191,7 +236,7 @@ module Aws
191
236
  if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] ||
192
237
  ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
193
238
  ECSCredentials.new(options)
194
- else
239
+ elsif !(ENV.fetch('AWS_EC2_METADATA_DISABLED', 'false').downcase == 'true')
195
240
  InstanceProfileCredentials.new(options.merge(profile: profile_name))
196
241
  end
197
242
  end
@@ -201,10 +246,14 @@ module Aws
201
246
  profile: profile_name,
202
247
  chain_config: @config
203
248
  }
204
- if options[:config] && options[:config].region
249
+ if options[:config]&.region
205
250
  assume_opts[:region] = options[:config].region
206
251
  end
207
252
  Aws.shared_config.assume_role_credentials_from_config(assume_opts)
208
253
  end
254
+
255
+ def with_metrics(metrics, &block)
256
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
257
+ end
209
258
  end
210
259
  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 = {})
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'cgi'
3
+ require "cgi/escape"
4
+ require "cgi/util" if RUBY_VERSION < "3.5"
4
5
 
5
6
  module Aws
6
7
  module Endpoints
@@ -19,19 +19,28 @@ require 'aws-sigv4'
19
19
  module Aws
20
20
  # @api private
21
21
  module Endpoints
22
- SUPPORTED_AUTH_TRAITS = %w[
23
- aws.auth#sigv4
24
- aws.auth#sigv4a
25
- smithy.api#httpBearerAuth
26
- smithy.api#noAuth
27
- ].freeze
22
+ # Maps config auth scheme preferences to endpoint auth scheme names.
23
+ ENDPOINT_AUTH_PREFERENCE_MAP = {
24
+ 'sigv4' => %w[sigv4 sigv4-s3express],
25
+ 'sigv4a' => ['sigv4a'],
26
+ 'httpBearerAuth' => ['bearer'],
27
+ 'noAuth' => ['none']
28
+ }.freeze
29
+ SUPPORTED_ENDPOINT_AUTH = ENDPOINT_AUTH_PREFERENCE_MAP.values.flatten.freeze
30
+
31
+ # Maps configured auth scheme preferences to modeled auth traits.
32
+ MODELED_AUTH_PREFERENCE_MAP = {
33
+ 'sigv4' => 'aws.auth#sigv4',
34
+ 'sigv4a' => 'aws.auth#sigv4a',
35
+ 'httpBearerAuth' => 'smithy.api#httpBearerAuth',
36
+ 'noAuth' => 'smithy.api#noAuth'
37
+ }.freeze
38
+ SUPPORTED_MODELED_AUTH = MODELED_AUTH_PREFERENCE_MAP.values.freeze
28
39
 
29
40
  class << self
30
41
  def resolve_auth_scheme(context, endpoint)
31
42
  if endpoint && (auth_schemes = endpoint.properties['authSchemes'])
32
- auth_scheme = auth_schemes.find do |scheme|
33
- Aws::Plugins::Sign::SUPPORTED_AUTH_TYPES.include?(scheme['name'])
34
- end
43
+ auth_scheme = endpoint_auth_scheme_preference(auth_schemes, context.config.auth_scheme_preference)
35
44
  raise 'No supported auth scheme for this endpoint.' unless auth_scheme
36
45
 
37
46
  merge_signing_defaults(auth_scheme, context.config)
@@ -42,6 +51,16 @@ module Aws
42
51
 
43
52
  private
44
53
 
54
+ def endpoint_auth_scheme_preference(auth_schemes, preferred_auth)
55
+ ordered_auth = preferred_auth.each_with_object([]) do |pref, list|
56
+ next unless ENDPOINT_AUTH_PREFERENCE_MAP.key?(pref)
57
+
58
+ ENDPOINT_AUTH_PREFERENCE_MAP[pref].each { |name| list << { 'name' => name } }
59
+ end
60
+ ordered_auth += auth_schemes
61
+ ordered_auth.find { |auth| SUPPORTED_ENDPOINT_AUTH.include?(auth['name']) }
62
+ end
63
+
45
64
  def merge_signing_defaults(auth_scheme, config)
46
65
  if %w[sigv4 sigv4a sigv4-s3express].include?(auth_scheme['name'])
47
66
  auth_scheme['signingName'] ||= sigv4_name(config)
@@ -64,13 +83,12 @@ module Aws
64
83
  end
65
84
 
66
85
  def sigv4_name(config)
67
- config.api.metadata['signingName'] ||
68
- config.api.metadata['endpointPrefix']
86
+ config.api.metadata['signingName'] || config.api.metadata['endpointPrefix']
69
87
  end
70
88
 
71
89
  def default_auth_scheme(context)
72
- if (auth_list = default_api_auth(context))
73
- auth = auth_list.find { |a| SUPPORTED_AUTH_TRAITS.include?(a) }
90
+ if (modeled_auth = default_api_auth(context))
91
+ auth = modeled_auth_scheme_preference(modeled_auth, context.config.auth_scheme_preference)
74
92
  case auth
75
93
  when 'aws.auth#sigv4', 'aws.auth#sigv4a'
76
94
  auth_scheme = { 'name' => auth.split('#').last }
@@ -93,6 +111,12 @@ module Aws
93
111
  end
94
112
  end
95
113
 
114
+ def modeled_auth_scheme_preference(modeled_auth, preferred_auth)
115
+ ordered_auth = preferred_auth.map { |pref| MODELED_AUTH_PREFERENCE_MAP[pref] }.compact
116
+ ordered_auth += modeled_auth
117
+ ordered_auth.find { |auth| SUPPORTED_MODELED_AUTH.include?(auth) }
118
+ end
119
+
96
120
  def default_api_auth(context)
97
121
  context.config.api.operation(context.operation_name)['auth'] ||
98
122
  context.config.api.metadata['auth']
@@ -1,12 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aws
4
+ # @api private
4
5
  class ErrorHandler < Seahorse::Client::Handler
5
6
 
6
7
  private
7
8
 
8
9
  def error(context)
9
10
  body = context.http_response.body_contents
11
+ # This is not correct per protocol tests. Some headers will determine the error code.
12
+ # If the body is empty, there is still potentially an error code from the header, but
13
+ # we are making a generic http status error instead. In a new major version, we should
14
+ # always try to extract header, and during extraction, check headers and body.
10
15
  if body.empty?
11
16
  code, message, data = http_status_error(context)
12
17
  else
@@ -213,6 +213,9 @@ module Aws
213
213
  # Raised when SSO Token is invalid
214
214
  class InvalidSSOToken < RuntimeError; end
215
215
 
216
+ # Raised when Login Token is invalid
217
+ class InvalidLoginToken < RuntimeError; end
218
+
216
219
  # Raised when a client is unable to sign a request because
217
220
  # the bearer token is not configured or available
218
221
  class MissingBearerTokenError < RuntimeError
@@ -31,7 +31,7 @@ module Aws
31
31
  def emit(type, params)
32
32
  unless @stream
33
33
  raise Aws::Errors::SignalEventError.new(
34
- "Singaling events before making async request"\
34
+ "Signaling events before making async request"\
35
35
  " is not allowed."
36
36
  )
37
37
  end