aws-sdk-core 3.209.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +331 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-core/arn.rb +1 -3
- data/lib/aws-sdk-core/assume_role_credentials.rb +9 -8
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +3 -2
- data/lib/aws-sdk-core/cbor/decoder.rb +0 -2
- data/lib/aws-sdk-core/cbor/encoder.rb +2 -2
- data/lib/aws-sdk-core/cbor.rb +3 -56
- data/lib/aws-sdk-core/client_stubs.rb +35 -55
- data/lib/aws-sdk-core/credential_provider.rb +4 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +91 -22
- data/lib/aws-sdk-core/credentials.rb +6 -0
- data/lib/aws-sdk-core/ecs_credentials.rb +14 -13
- data/lib/aws-sdk-core/endpoints/matchers.rb +3 -9
- data/lib/aws-sdk-core/endpoints.rb +37 -13
- data/lib/aws-sdk-core/error_handler.rb +5 -0
- data/lib/aws-sdk-core/errors.rb +5 -2
- data/lib/aws-sdk-core/event_emitter.rb +1 -1
- data/lib/aws-sdk-core/instance_profile_credentials.rb +147 -157
- data/lib/aws-sdk-core/json/error_handler.rb +14 -3
- data/lib/aws-sdk-core/json/handler.rb +1 -0
- data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
- data/lib/aws-sdk-core/login_credentials.rb +229 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +347 -171
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +0 -1
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +75 -59
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +44 -25
- data/lib/aws-sdk-core/plugins/sign.rb +30 -21
- data/lib/aws-sdk-core/plugins/stub_responses.rb +30 -8
- data/lib/aws-sdk-core/plugins/user_agent.rb +35 -2
- data/lib/aws-sdk-core/process_credentials.rb +1 -1
- data/lib/aws-sdk-core/refreshing_credentials.rb +8 -11
- data/lib/aws-sdk-core/rest/request/headers.rb +3 -3
- data/lib/aws-sdk-core/rpc_v2/builder.rb +1 -1
- data/lib/aws-sdk-core/{cbor → rpc_v2}/cbor_engine.rb +4 -5
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +3 -1
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +27 -16
- data/lib/aws-sdk-core/rpc_v2/handler.rb +2 -1
- data/lib/aws-sdk-core/rpc_v2/parser.rb +9 -1
- data/lib/aws-sdk-core/rpc_v2.rb +65 -2
- data/lib/aws-sdk-core/shared_config.rb +104 -21
- data/lib/aws-sdk-core/shared_credentials.rb +1 -0
- data/lib/aws-sdk-core/sso_credentials.rb +3 -1
- data/lib/aws-sdk-core/static_token_provider.rb +1 -2
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +13 -15
- data/lib/aws-sdk-core/stubbing.rb +2 -2
- data/lib/aws-sdk-core/token.rb +3 -3
- data/lib/aws-sdk-core/token_provider.rb +4 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +2 -6
- data/lib/aws-sdk-core/util.rb +2 -1
- data/lib/aws-sdk-core/xml/error_handler.rb +3 -1
- data/lib/aws-sdk-core.rb +4 -0
- data/lib/aws-sdk-signin/client.rb +604 -0
- data/lib/aws-sdk-signin/client_api.rb +119 -0
- data/lib/aws-sdk-signin/customizations.rb +1 -0
- data/lib/aws-sdk-signin/endpoint_parameters.rb +69 -0
- data/lib/aws-sdk-signin/endpoint_provider.rb +59 -0
- data/lib/aws-sdk-signin/endpoints.rb +20 -0
- data/lib/aws-sdk-signin/errors.rb +122 -0
- data/lib/aws-sdk-signin/plugins/endpoints.rb +77 -0
- data/lib/aws-sdk-signin/resource.rb +26 -0
- data/lib/aws-sdk-signin/types.rb +299 -0
- data/lib/aws-sdk-signin.rb +63 -0
- data/lib/aws-sdk-sso/client.rb +76 -47
- data/lib/aws-sdk-sso/endpoint_parameters.rb +13 -10
- data/lib/aws-sdk-sso/endpoint_provider.rb +16 -20
- data/lib/aws-sdk-sso/endpoints.rb +2 -42
- data/lib/aws-sdk-sso/plugins/endpoints.rb +1 -14
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +132 -73
- data/lib/aws-sdk-ssooidc/client_api.rb +11 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +13 -10
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
- data/lib/aws-sdk-ssooidc/endpoints.rb +2 -42
- data/lib/aws-sdk-ssooidc/errors.rb +10 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +1 -14
- data/lib/aws-sdk-ssooidc/types.rb +65 -21
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +416 -107
- data/lib/aws-sdk-sts/client_api.rb +105 -8
- data/lib/aws-sdk-sts/customizations.rb +0 -1
- data/lib/aws-sdk-sts/endpoint_parameters.rb +15 -14
- data/lib/aws-sdk-sts/endpoint_provider.rb +50 -55
- data/lib/aws-sdk-sts/endpoints.rb +2 -94
- data/lib/aws-sdk-sts/errors.rb +79 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +1 -22
- data/lib/aws-sdk-sts/presigner.rb +2 -6
- data/lib/aws-sdk-sts/types.rb +343 -32
- data/lib/aws-sdk-sts.rb +1 -1
- data/lib/seahorse/client/async_base.rb +4 -5
- data/lib/seahorse/client/base.rb +0 -14
- data/lib/seahorse/client/h2/connection.rb +18 -28
- data/lib/seahorse/client/h2/handler.rb +6 -1
- data/lib/seahorse/client/http/response.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +4 -1
- data/lib/seahorse/client/networking_error.rb +1 -1
- data/lib/seahorse/client/plugins/h2.rb +4 -4
- data/lib/seahorse/client/request_context.rb +2 -2
- data/lib/seahorse/client/response.rb +2 -0
- data/lib/seahorse/util.rb +2 -1
- data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
- data/sig/seahorse/client/async_base.rbs +18 -0
- metadata +69 -17
|
@@ -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
|
|
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,
|
|
@@ -42,51 +44,92 @@ module Aws
|
|
|
42
44
|
|
|
43
45
|
def static_credentials(options)
|
|
44
46
|
if options[:config]
|
|
45
|
-
Credentials.new(
|
|
47
|
+
creds = Credentials.new(
|
|
46
48
|
options[:config].access_key_id,
|
|
47
49
|
options[:config].secret_access_key,
|
|
48
50
|
options[:config].session_token,
|
|
49
51
|
account_id: options[:config].account_id
|
|
50
52
|
)
|
|
53
|
+
creds.metrics = ['CREDENTIALS_PROFILE']
|
|
54
|
+
creds
|
|
51
55
|
end
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
def static_profile_assume_role_web_identity_credentials(options)
|
|
55
|
-
|
|
56
|
-
|
|
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(
|
|
57
63
|
profile: options[:config].profile,
|
|
58
64
|
region: options[:config].region
|
|
59
65
|
)
|
|
66
|
+
return unless creds
|
|
67
|
+
|
|
68
|
+
creds.metrics << 'CREDENTIALS_CODE'
|
|
69
|
+
creds
|
|
60
70
|
end
|
|
61
71
|
end
|
|
62
72
|
|
|
63
73
|
def static_profile_sso_credentials(options)
|
|
64
|
-
|
|
65
|
-
|
|
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(
|
|
66
78
|
profile: options[:config].profile
|
|
67
79
|
)
|
|
80
|
+
return unless creds
|
|
81
|
+
|
|
82
|
+
creds.metrics << 'CREDENTIALS_CODE'
|
|
83
|
+
creds
|
|
68
84
|
end
|
|
69
85
|
end
|
|
70
86
|
|
|
71
87
|
def static_profile_assume_role_credentials(options)
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
74
96
|
end
|
|
75
97
|
end
|
|
76
98
|
|
|
77
99
|
def static_profile_credentials(options)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
return unless options[:config]&.profile
|
|
101
|
+
|
|
102
|
+
creds = SharedCredentials.new(profile_name: options[:config].profile)
|
|
103
|
+
creds.metrics << 'CREDENTIALS_PROFILE'
|
|
104
|
+
creds
|
|
81
105
|
rescue Errors::NoSuchProfileError
|
|
82
106
|
nil
|
|
83
107
|
end
|
|
84
108
|
|
|
85
|
-
def
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
89
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
|
|
90
133
|
rescue Errors::NoSuchProfileError
|
|
91
134
|
nil
|
|
92
135
|
end
|
|
@@ -96,12 +139,14 @@ module Aws
|
|
|
96
139
|
secret = %w[AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY]
|
|
97
140
|
token = %w[AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN]
|
|
98
141
|
account_id = %w[AWS_ACCOUNT_ID]
|
|
99
|
-
Credentials.new(
|
|
142
|
+
creds = Credentials.new(
|
|
100
143
|
envar(key),
|
|
101
144
|
envar(secret),
|
|
102
145
|
envar(token),
|
|
103
146
|
account_id: envar(account_id)
|
|
104
147
|
)
|
|
148
|
+
creds.metrics = ['CREDENTIALS_ENV_VARS']
|
|
149
|
+
creds
|
|
105
150
|
end
|
|
106
151
|
|
|
107
152
|
def envar(keys)
|
|
@@ -112,12 +157,24 @@ module Aws
|
|
|
112
157
|
end
|
|
113
158
|
|
|
114
159
|
def determine_profile_name(options)
|
|
115
|
-
(options[:config]
|
|
160
|
+
(options[:config]&.profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
|
|
116
161
|
end
|
|
117
162
|
|
|
118
163
|
def shared_credentials(options)
|
|
119
164
|
profile_name = determine_profile_name(options)
|
|
120
|
-
SharedCredentials.new(profile_name: profile_name)
|
|
165
|
+
creds = SharedCredentials.new(profile_name: profile_name)
|
|
166
|
+
creds.metrics = ['CREDENTIALS_PROFILE']
|
|
167
|
+
creds
|
|
168
|
+
rescue Errors::NoSuchProfileError
|
|
169
|
+
nil
|
|
170
|
+
end
|
|
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)
|
|
121
178
|
rescue Errors::NoSuchProfileError
|
|
122
179
|
nil
|
|
123
180
|
end
|
|
@@ -126,7 +183,11 @@ module Aws
|
|
|
126
183
|
profile_name = determine_profile_name(options)
|
|
127
184
|
if Aws.shared_config.config_enabled?
|
|
128
185
|
process_provider = Aws.shared_config.credential_process(profile: profile_name)
|
|
129
|
-
|
|
186
|
+
if process_provider
|
|
187
|
+
creds = ProcessCredentials.new([process_provider])
|
|
188
|
+
creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
|
|
189
|
+
creds
|
|
190
|
+
end
|
|
130
191
|
end
|
|
131
192
|
rescue Errors::NoSuchProfileError
|
|
132
193
|
nil
|
|
@@ -156,7 +217,11 @@ module Aws
|
|
|
156
217
|
role_session_name: ENV['AWS_ROLE_SESSION_NAME']
|
|
157
218
|
}
|
|
158
219
|
cfg[:region] = region if region
|
|
159
|
-
|
|
220
|
+
Aws::Plugins::UserAgent.metric('CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN') do
|
|
221
|
+
creds = AssumeRoleWebIdentityCredentials.new(cfg)
|
|
222
|
+
creds.metrics << 'CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN'
|
|
223
|
+
creds
|
|
224
|
+
end
|
|
160
225
|
elsif Aws.shared_config.config_enabled?
|
|
161
226
|
profile = options[:config].profile if options[:config]
|
|
162
227
|
Aws.shared_config.assume_role_web_identity_credentials_from_config(
|
|
@@ -171,7 +236,7 @@ module Aws
|
|
|
171
236
|
if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] ||
|
|
172
237
|
ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
|
|
173
238
|
ECSCredentials.new(options)
|
|
174
|
-
|
|
239
|
+
elsif !(ENV.fetch('AWS_EC2_METADATA_DISABLED', 'false').downcase == 'true')
|
|
175
240
|
InstanceProfileCredentials.new(options.merge(profile: profile_name))
|
|
176
241
|
end
|
|
177
242
|
end
|
|
@@ -181,10 +246,14 @@ module Aws
|
|
|
181
246
|
profile: profile_name,
|
|
182
247
|
chain_config: @config
|
|
183
248
|
}
|
|
184
|
-
if options[:config]
|
|
249
|
+
if options[:config]&.region
|
|
185
250
|
assume_opts[:region] = options[:config].region
|
|
186
251
|
end
|
|
187
252
|
Aws.shared_config.assume_role_credentials_from_config(assume_opts)
|
|
188
253
|
end
|
|
254
|
+
|
|
255
|
+
def with_metrics(metrics, &block)
|
|
256
|
+
Aws::Plugins::UserAgent.metric(*metrics, &block)
|
|
257
|
+
end
|
|
189
258
|
end
|
|
190
259
|
end
|
|
@@ -14,6 +14,7 @@ module Aws
|
|
|
14
14
|
@secret_access_key = secret_access_key
|
|
15
15
|
@session_token = session_token
|
|
16
16
|
@account_id = kwargs[:account_id]
|
|
17
|
+
@metrics = ['CREDENTIALS_CODE']
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
# @return [String]
|
|
@@ -28,6 +29,11 @@ module Aws
|
|
|
28
29
|
# @return [String, nil]
|
|
29
30
|
attr_reader :account_id
|
|
30
31
|
|
|
32
|
+
# @api private
|
|
33
|
+
# Returns the credentials source. Used for tracking credentials
|
|
34
|
+
# related UserAgent metrics.
|
|
35
|
+
attr_accessor :metrics
|
|
36
|
+
|
|
31
37
|
# @return [Credentials]
|
|
32
38
|
def credentials
|
|
33
39
|
self
|
|
@@ -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
|
|
46
|
-
# @option options [Integer] :port (80) This value is ignored if
|
|
47
|
-
# is set and
|
|
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
|
|
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 [
|
|
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 [
|
|
61
|
-
#
|
|
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 = {})
|
|
@@ -77,6 +77,7 @@ module Aws
|
|
|
77
77
|
@http_debug_output = options[:http_debug_output]
|
|
78
78
|
@backoff = backoff(options[:backoff])
|
|
79
79
|
@async_refresh = false
|
|
80
|
+
@metrics = ['CREDENTIALS_HTTP']
|
|
80
81
|
super
|
|
81
82
|
end
|
|
82
83
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "cgi/escape"
|
|
4
|
+
require "cgi/util" if RUBY_VERSION < "3.5"
|
|
4
5
|
|
|
5
6
|
module Aws
|
|
6
7
|
module Endpoints
|
|
@@ -94,14 +95,7 @@ module Aws
|
|
|
94
95
|
|
|
95
96
|
# aws.partition(value: string) Option<Partition>
|
|
96
97
|
def self.aws_partition(value)
|
|
97
|
-
partition
|
|
98
|
-
Aws::Partitions.find { |p| p.region?(value) } ||
|
|
99
|
-
Aws::Partitions.find { |p| value.match(p.region_regex) } ||
|
|
100
|
-
Aws::Partitions.find { |p| p.name == 'aws' }
|
|
101
|
-
|
|
102
|
-
return nil unless partition
|
|
103
|
-
|
|
104
|
-
partition.metadata
|
|
98
|
+
Aws::Partitions::Metadata.partition(value)
|
|
105
99
|
end
|
|
106
100
|
|
|
107
101
|
# aws.parseArn(value: string) Option<ARN>
|
|
@@ -19,19 +19,28 @@ require 'aws-sigv4'
|
|
|
19
19
|
module Aws
|
|
20
20
|
# @api private
|
|
21
21
|
module Endpoints
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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.
|
|
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 (
|
|
73
|
-
auth =
|
|
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
|
data/lib/aws-sdk-core/errors.rb
CHANGED
|
@@ -68,7 +68,7 @@ module Aws
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
#
|
|
71
|
+
# Raised when endpoint discovery failed for operations
|
|
72
72
|
# that requires endpoints from endpoint discovery
|
|
73
73
|
class EndpointDiscoveryError < RuntimeError
|
|
74
74
|
def initialize(*args)
|
|
@@ -78,7 +78,7 @@ module Aws
|
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
#
|
|
81
|
+
# Raised when hostLabel member is not provided
|
|
82
82
|
# at operation input when endpoint trait is available
|
|
83
83
|
# with 'hostPrefix' requirement
|
|
84
84
|
class MissingEndpointHostLabelValue < RuntimeError
|
|
@@ -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
|