aws-sdk-core 3.100.0 → 3.191.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1815 -0
- data/LICENSE.txt +202 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +153 -0
- data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
- data/lib/aws-defaults.rb +3 -0
- data/lib/aws-sdk-core/arn.rb +28 -0
- data/lib/aws-sdk-core/arn_parser.rb +2 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +23 -7
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +16 -10
- data/lib/aws-sdk-core/async_client_stubs.rb +2 -0
- data/lib/aws-sdk-core/binary/decode_handler.rb +2 -0
- data/lib/aws-sdk-core/binary/encode_handler.rb +14 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_parser.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +2 -0
- data/lib/aws-sdk-core/binary.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +2 -0
- data/lib/aws-sdk-core/client_stubs.rb +22 -13
- data/lib/aws-sdk-core/credential_provider.rb +5 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +31 -6
- data/lib/aws-sdk-core/credentials.rb +2 -0
- data/lib/aws-sdk-core/deprecations.rb +2 -0
- data/lib/aws-sdk-core/eager_loader.rb +2 -0
- data/lib/aws-sdk-core/ec2_metadata.rb +238 -0
- data/lib/aws-sdk-core/ecs_credentials.rb +188 -53
- data/lib/aws-sdk-core/endpoint_cache.rb +2 -0
- data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
- data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
- data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
- data/lib/aws-sdk-core/endpoints/function.rb +80 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +131 -0
- data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
- data/lib/aws-sdk-core/endpoints/url.rb +60 -0
- data/lib/aws-sdk-core/endpoints.rb +78 -0
- data/lib/aws-sdk-core/errors.rb +27 -5
- data/lib/aws-sdk-core/event_emitter.rb +2 -0
- data/lib/aws-sdk-core/ini_parser.rb +9 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +167 -38
- data/lib/aws-sdk-core/json/builder.rb +2 -0
- data/lib/aws-sdk-core/json/error_handler.rb +22 -1
- data/lib/aws-sdk-core/json/handler.rb +10 -1
- data/lib/aws-sdk-core/json/json_engine.rb +12 -8
- data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
- data/lib/aws-sdk-core/json/parser.rb +36 -1
- data/lib/aws-sdk-core/json.rb +10 -26
- data/lib/aws-sdk-core/log/formatter.rb +15 -3
- data/lib/aws-sdk-core/log/handler.rb +2 -0
- data/lib/aws-sdk-core/log/param_filter.rb +37 -12
- data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
- data/lib/aws-sdk-core/pageable_response.rb +91 -32
- data/lib/aws-sdk-core/pager.rb +5 -0
- data/lib/aws-sdk-core/param_converter.rb +2 -0
- data/lib/aws-sdk-core/param_validator.rb +56 -6
- data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
- data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +342 -0
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +3 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +2 -0
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +52 -7
- data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +8 -2
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +8 -6
- data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
- data/lib/aws-sdk-core/plugins/http_checksum.rb +11 -1
- data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/invocation_id.rb +2 -0
- data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +36 -6
- data/lib/aws-sdk-core/plugins/logging.rb +4 -0
- data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
- data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
- data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +146 -17
- data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
- data/lib/aws-sdk-core/plugins/response_paging.rb +3 -1
- data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +9 -4
- data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +2 -0
- data/lib/aws-sdk-core/plugins/retry_errors.rb +29 -8
- data/lib/aws-sdk-core/plugins/sign.rb +206 -0
- data/lib/aws-sdk-core/plugins/signature_v2.rb +3 -0
- data/lib/aws-sdk-core/plugins/signature_v4.rb +30 -31
- data/lib/aws-sdk-core/plugins/stub_responses.rb +10 -1
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +2 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +119 -14
- data/lib/aws-sdk-core/process_credentials.rb +14 -15
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/handler.rb +2 -0
- data/lib/aws-sdk-core/query/param.rb +2 -0
- data/lib/aws-sdk-core/query/param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/param_list.rb +2 -0
- data/lib/aws-sdk-core/query.rb +2 -0
- data/lib/aws-sdk-core/refreshing_credentials.rb +50 -17
- data/lib/aws-sdk-core/refreshing_token.rb +71 -0
- data/lib/aws-sdk-core/resources/collection.rb +2 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -1
- data/lib/aws-sdk-core/rest/request/body.rb +21 -1
- data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +2 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +16 -6
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +45 -29
- data/lib/aws-sdk-core/rest/response/body.rb +2 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
- data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
- data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
- data/lib/aws-sdk-core/rest.rb +2 -0
- data/lib/aws-sdk-core/shared_config.rb +163 -8
- data/lib/aws-sdk-core/shared_credentials.rb +9 -1
- data/lib/aws-sdk-core/sso_credentials.rb +172 -0
- data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
- data/lib/aws-sdk-core/static_token_provider.rb +14 -0
- data/lib/aws-sdk-core/structure.rb +19 -6
- data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
- data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
- data/lib/aws-sdk-core/stubbing/stub_data.rb +13 -0
- data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
- data/lib/aws-sdk-core/token.rb +31 -0
- data/lib/aws-sdk-core/token_provider.rb +15 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
- data/lib/aws-sdk-core/type_builder.rb +2 -0
- data/lib/aws-sdk-core/util.rb +2 -0
- data/lib/aws-sdk-core/waiters/errors.rb +2 -0
- data/lib/aws-sdk-core/waiters/poller.rb +6 -2
- data/lib/aws-sdk-core/waiters/waiter.rb +2 -0
- data/lib/aws-sdk-core/waiters.rb +2 -0
- data/lib/aws-sdk-core/xml/builder.rb +4 -2
- data/lib/aws-sdk-core/xml/default_list.rb +2 -0
- data/lib/aws-sdk-core/xml/default_map.rb +2 -0
- data/lib/aws-sdk-core/xml/doc_builder.rb +8 -1
- data/lib/aws-sdk-core/xml/error_handler.rb +9 -0
- data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/oga.rb +4 -0
- data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
- data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
- data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +7 -0
- data/lib/aws-sdk-core/xml.rb +2 -0
- data/lib/aws-sdk-core.rb +29 -3
- data/lib/aws-sdk-sso/client.rb +630 -0
- data/lib/aws-sdk-sso/client_api.rb +190 -0
- data/lib/aws-sdk-sso/customizations.rb +1 -0
- data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-sso/endpoints.rb +72 -0
- data/lib/aws-sdk-sso/errors.rb +102 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-sso/resource.rb +26 -0
- data/lib/aws-sdk-sso/types.rb +317 -0
- data/lib/aws-sdk-sso.rb +59 -0
- data/lib/aws-sdk-ssooidc/client.rb +935 -0
- data/lib/aws-sdk-ssooidc/client_api.rb +271 -0
- data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-ssooidc/endpoints.rb +72 -0
- data/lib/aws-sdk-ssooidc/errors.rb +321 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-ssooidc/resource.rb +26 -0
- data/lib/aws-sdk-ssooidc/types.rb +755 -0
- data/lib/aws-sdk-ssooidc.rb +59 -0
- data/lib/aws-sdk-sts/client.rb +655 -490
- data/lib/aws-sdk-sts/client_api.rb +21 -2
- data/lib/aws-sdk-sts/customizations.rb +2 -0
- data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
- data/lib/aws-sdk-sts/endpoint_provider.rb +112 -0
- data/lib/aws-sdk-sts/endpoints.rb +136 -0
- data/lib/aws-sdk-sts/errors.rb +3 -1
- data/lib/aws-sdk-sts/plugins/endpoints.rb +86 -0
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +7 -1
- data/lib/aws-sdk-sts/presigner.rb +16 -10
- data/lib/aws-sdk-sts/resource.rb +3 -1
- data/lib/aws-sdk-sts/types.rb +416 -316
- data/lib/aws-sdk-sts.rb +14 -3
- data/lib/seahorse/client/async_base.rb +2 -1
- data/lib/seahorse/client/async_response.rb +2 -0
- data/lib/seahorse/client/base.rb +3 -0
- data/lib/seahorse/client/block_io.rb +5 -2
- data/lib/seahorse/client/configuration.rb +7 -5
- data/lib/seahorse/client/events.rb +2 -0
- data/lib/seahorse/client/h2/connection.rb +29 -24
- data/lib/seahorse/client/h2/handler.rb +6 -5
- data/lib/seahorse/client/handler.rb +2 -0
- data/lib/seahorse/client/handler_builder.rb +2 -0
- data/lib/seahorse/client/handler_list.rb +2 -0
- data/lib/seahorse/client/handler_list_entry.rb +2 -0
- data/lib/seahorse/client/http/async_response.rb +2 -0
- data/lib/seahorse/client/http/headers.rb +2 -0
- data/lib/seahorse/client/http/request.rb +2 -0
- data/lib/seahorse/client/http/response.rb +3 -1
- data/lib/seahorse/client/logging/formatter.rb +2 -0
- data/lib/seahorse/client/logging/handler.rb +2 -0
- data/lib/seahorse/client/managed_file.rb +2 -0
- data/lib/seahorse/client/net_http/connection_pool.rb +12 -4
- data/lib/seahorse/client/net_http/handler.rb +19 -8
- data/lib/seahorse/client/net_http/patches.rb +14 -86
- data/lib/seahorse/client/networking_error.rb +2 -0
- data/lib/seahorse/client/plugin.rb +3 -0
- data/lib/seahorse/client/plugin_list.rb +2 -0
- data/lib/seahorse/client/plugins/content_length.rb +13 -5
- data/lib/seahorse/client/plugins/endpoint.rb +2 -0
- data/lib/seahorse/client/plugins/h2.rb +9 -4
- data/lib/seahorse/client/plugins/logging.rb +2 -0
- data/lib/seahorse/client/plugins/net_http.rb +39 -3
- data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
- data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
- data/lib/seahorse/client/plugins/request_callback.rb +141 -0
- data/lib/seahorse/client/plugins/response_target.rb +8 -8
- data/lib/seahorse/client/request.rb +2 -0
- data/lib/seahorse/client/request_context.rb +2 -0
- data/lib/seahorse/client/response.rb +8 -0
- data/lib/seahorse/model/api.rb +2 -0
- data/lib/seahorse/model/authorizer.rb +2 -0
- data/lib/seahorse/model/operation.rb +8 -0
- data/lib/seahorse/model/shapes.rb +27 -0
- data/lib/seahorse/util.rb +12 -1
- data/lib/seahorse/version.rb +2 -0
- data/lib/seahorse.rb +3 -0
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -0
- data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +93 -19
@@ -0,0 +1,342 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Plugins
|
5
|
+
# @api private
|
6
|
+
class ChecksumAlgorithm < Seahorse::Client::Plugin
|
7
|
+
CHUNK_SIZE = 1 * 1024 * 1024 # one MB
|
8
|
+
|
9
|
+
# determine the set of supported client side checksum algorithms
|
10
|
+
# CRC32c requires aws-crt (optional sdk dependency) for support
|
11
|
+
CLIENT_ALGORITHMS = begin
|
12
|
+
supported = %w[SHA256 SHA1 CRC32]
|
13
|
+
begin
|
14
|
+
require 'aws-crt'
|
15
|
+
supported << 'CRC32C'
|
16
|
+
rescue LoadError
|
17
|
+
end
|
18
|
+
supported
|
19
|
+
end.freeze
|
20
|
+
|
21
|
+
# priority order of checksum algorithms to validate responses against
|
22
|
+
# Remove any algorithms not supported by client (ie, depending on CRT availability)
|
23
|
+
CHECKSUM_ALGORITHM_PRIORITIES = %w[CRC32C SHA1 CRC32 SHA256] & CLIENT_ALGORITHMS
|
24
|
+
|
25
|
+
# byte size of checksums, used in computing the trailer length
|
26
|
+
CHECKSUM_SIZE = {
|
27
|
+
'CRC32' => 16,
|
28
|
+
'CRC32C' => 16,
|
29
|
+
'SHA1' => 36,
|
30
|
+
'SHA256' => 52
|
31
|
+
}
|
32
|
+
|
33
|
+
# Interface for computing digests on request/response bodies
|
34
|
+
# which may be files, strings or IO like objects
|
35
|
+
# Applies only to digest functions that produce 32 bit integer checksums
|
36
|
+
# (eg CRC32)
|
37
|
+
class Digest32
|
38
|
+
|
39
|
+
attr_reader :value
|
40
|
+
|
41
|
+
# @param [Object] digest_fn
|
42
|
+
def initialize(digest_fn)
|
43
|
+
@digest_fn = digest_fn
|
44
|
+
@value = 0
|
45
|
+
end
|
46
|
+
|
47
|
+
def update(chunk)
|
48
|
+
@value = @digest_fn.call(chunk, @value)
|
49
|
+
end
|
50
|
+
|
51
|
+
def base64digest
|
52
|
+
Base64.encode64([@value].pack('N')).chomp
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_handlers(handlers, _config)
|
57
|
+
handlers.add(OptionHandler, step: :initialize)
|
58
|
+
# priority set low to ensure checksum is computed AFTER the request is
|
59
|
+
# built but before it is signed
|
60
|
+
handlers.add(ChecksumHandler, priority: 15, step: :build)
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def self.request_algorithm_selection(context)
|
66
|
+
return unless context.operation.http_checksum
|
67
|
+
|
68
|
+
input_member = context.operation.http_checksum['requestAlgorithmMember']
|
69
|
+
context.params[input_member.to_sym]&.upcase if input_member
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.request_validation_mode(context)
|
73
|
+
return unless context.operation.http_checksum
|
74
|
+
|
75
|
+
input_member = context.operation.http_checksum['requestValidationModeMember']
|
76
|
+
context.params[input_member.to_sym] if input_member
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.operation_response_algorithms(context)
|
80
|
+
return unless context.operation.http_checksum
|
81
|
+
|
82
|
+
context.operation.http_checksum['responseAlgorithms']
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
# @api private
|
87
|
+
class OptionHandler < Seahorse::Client::Handler
|
88
|
+
def call(context)
|
89
|
+
context[:http_checksum] ||= {}
|
90
|
+
|
91
|
+
# validate request configuration
|
92
|
+
if (request_input = ChecksumAlgorithm.request_algorithm_selection(context))
|
93
|
+
unless CLIENT_ALGORITHMS.include? request_input
|
94
|
+
if (request_input == 'CRC32C')
|
95
|
+
raise ArgumentError, "CRC32C requires crt support - install the aws-crt gem for support."
|
96
|
+
else
|
97
|
+
raise ArgumentError, "#{request_input} is not a supported checksum algorithm."
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# validate response configuration
|
103
|
+
if (ChecksumAlgorithm.request_validation_mode(context))
|
104
|
+
# Compute an ordered list as the union between priority supported and the
|
105
|
+
# operation's modeled response algorithms.
|
106
|
+
validation_list = CHECKSUM_ALGORITHM_PRIORITIES &
|
107
|
+
ChecksumAlgorithm.operation_response_algorithms(context)
|
108
|
+
context[:http_checksum][:validation_list] = validation_list
|
109
|
+
end
|
110
|
+
|
111
|
+
@handler.call(context)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# @api private
|
116
|
+
class ChecksumHandler < Seahorse::Client::Handler
|
117
|
+
|
118
|
+
def call(context)
|
119
|
+
if should_calculate_request_checksum?(context)
|
120
|
+
request_algorithm_input = ChecksumAlgorithm.request_algorithm_selection(context) ||
|
121
|
+
context[:default_request_checksum_algorithm]
|
122
|
+
context[:checksum_algorithms] = request_algorithm_input
|
123
|
+
|
124
|
+
request_checksum_property = {
|
125
|
+
'algorithm' => request_algorithm_input,
|
126
|
+
'in' => checksum_request_in(context),
|
127
|
+
'name' => "x-amz-checksum-#{request_algorithm_input.downcase}"
|
128
|
+
}
|
129
|
+
|
130
|
+
calculate_request_checksum(context, request_checksum_property)
|
131
|
+
end
|
132
|
+
|
133
|
+
if should_verify_response_checksum?(context)
|
134
|
+
add_verify_response_checksum_handlers(context)
|
135
|
+
end
|
136
|
+
|
137
|
+
@handler.call(context)
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def should_calculate_request_checksum?(context)
|
143
|
+
context.operation.http_checksum &&
|
144
|
+
(ChecksumAlgorithm.request_algorithm_selection(context) ||
|
145
|
+
context[:default_request_checksum_algorithm])
|
146
|
+
end
|
147
|
+
|
148
|
+
def should_verify_response_checksum?(context)
|
149
|
+
context[:http_checksum][:validation_list] && !context[:http_checksum][:validation_list].empty?
|
150
|
+
end
|
151
|
+
|
152
|
+
def calculate_request_checksum(context, checksum_properties)
|
153
|
+
case checksum_properties['in']
|
154
|
+
when 'header'
|
155
|
+
header_name = checksum_properties['name']
|
156
|
+
body = context.http_request.body_contents
|
157
|
+
if body
|
158
|
+
context.http_request.headers[header_name] ||=
|
159
|
+
ChecksumAlgorithm.calculate_checksum(checksum_properties['algorithm'], body)
|
160
|
+
end
|
161
|
+
when 'trailer'
|
162
|
+
apply_request_trailer_checksum(context, checksum_properties)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def apply_request_trailer_checksum(context, checksum_properties)
|
167
|
+
location_name = checksum_properties['name']
|
168
|
+
|
169
|
+
# set required headers
|
170
|
+
headers = context.http_request.headers
|
171
|
+
headers['Content-Encoding'] = 'aws-chunked'
|
172
|
+
headers['X-Amz-Content-Sha256'] = 'STREAMING-UNSIGNED-PAYLOAD-TRAILER'
|
173
|
+
headers['X-Amz-Trailer'] = location_name
|
174
|
+
|
175
|
+
# We currently always compute the size in the modified body wrapper - allowing us
|
176
|
+
# to set the Content-Length header (set by content_length plugin).
|
177
|
+
# This means we cannot use Transfer-Encoding=chunked
|
178
|
+
|
179
|
+
if !context.http_request.body.respond_to?(:size)
|
180
|
+
raise Aws::Errors::ChecksumError, 'Could not determine length of the body'
|
181
|
+
end
|
182
|
+
headers['X-Amz-Decoded-Content-Length'] = context.http_request.body.size
|
183
|
+
|
184
|
+
context.http_request.body = AwsChunkedTrailerDigestIO.new(
|
185
|
+
context.http_request.body,
|
186
|
+
checksum_properties['algorithm'],
|
187
|
+
location_name
|
188
|
+
)
|
189
|
+
end
|
190
|
+
|
191
|
+
# Add events to the http_response to verify the checksum as its read
|
192
|
+
# This prevents the body from being read multiple times
|
193
|
+
# verification is done only once a successful response has completed
|
194
|
+
def add_verify_response_checksum_handlers(context)
|
195
|
+
http_response = context.http_response
|
196
|
+
checksum_context = { }
|
197
|
+
http_response.on_headers do |_status, headers|
|
198
|
+
header_name, algorithm = response_header_to_verify(headers, context[:http_checksum][:validation_list])
|
199
|
+
if header_name
|
200
|
+
expected = headers[header_name]
|
201
|
+
|
202
|
+
unless context[:http_checksum][:skip_on_suffix] && /-[\d]+$/.match(expected)
|
203
|
+
checksum_context[:algorithm] = algorithm
|
204
|
+
checksum_context[:header_name] = header_name
|
205
|
+
checksum_context[:digest] = ChecksumAlgorithm.digest_for_algorithm(algorithm)
|
206
|
+
checksum_context[:expected] = expected
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
http_response.on_data do |chunk|
|
212
|
+
checksum_context[:digest].update(chunk) if checksum_context[:digest]
|
213
|
+
end
|
214
|
+
|
215
|
+
http_response.on_success do
|
216
|
+
if checksum_context[:digest] &&
|
217
|
+
(computed = checksum_context[:digest].base64digest)
|
218
|
+
|
219
|
+
if computed != checksum_context[:expected]
|
220
|
+
raise Aws::Errors::ChecksumError,
|
221
|
+
"Checksum validation failed on #{checksum_context[:header_name]} "\
|
222
|
+
"computed: #{computed}, expected: #{checksum_context[:expected]}"
|
223
|
+
end
|
224
|
+
|
225
|
+
context[:http_checksum][:validated] = checksum_context[:algorithm]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# returns nil if no headers to verify
|
231
|
+
def response_header_to_verify(headers, validation_list)
|
232
|
+
validation_list.each do |algorithm|
|
233
|
+
header_name = "x-amz-checksum-#{algorithm}"
|
234
|
+
return [header_name, algorithm] if headers[header_name]
|
235
|
+
end
|
236
|
+
nil
|
237
|
+
end
|
238
|
+
|
239
|
+
# determine where (header vs trailer) a request checksum should be added
|
240
|
+
def checksum_request_in(context)
|
241
|
+
if context.operation['authtype'].eql?('v4-unsigned-body')
|
242
|
+
'trailer'
|
243
|
+
else
|
244
|
+
'header'
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
def self.calculate_checksum(algorithm, body)
|
251
|
+
digest = ChecksumAlgorithm.digest_for_algorithm(algorithm)
|
252
|
+
if body.respond_to?(:read)
|
253
|
+
ChecksumAlgorithm.update_in_chunks(digest, body)
|
254
|
+
else
|
255
|
+
digest.update(body)
|
256
|
+
end
|
257
|
+
digest.base64digest
|
258
|
+
end
|
259
|
+
|
260
|
+
def self.digest_for_algorithm(algorithm)
|
261
|
+
case algorithm
|
262
|
+
when 'CRC32'
|
263
|
+
Digest32.new(Zlib.method(:crc32))
|
264
|
+
when 'CRC32C'
|
265
|
+
# this will only be used if input algorithm is CRC32C AND client supports it (crt available)
|
266
|
+
Digest32.new(Aws::Crt::Checksums.method(:crc32c))
|
267
|
+
when 'SHA1'
|
268
|
+
Digest::SHA1.new
|
269
|
+
when 'SHA256'
|
270
|
+
Digest::SHA256.new
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# The trailer size (in bytes) is the overhead + the trailer name +
|
275
|
+
# the length of the base64 encoded checksum
|
276
|
+
def self.trailer_length(algorithm, location_name)
|
277
|
+
CHECKSUM_SIZE[algorithm] + location_name.size
|
278
|
+
end
|
279
|
+
|
280
|
+
def self.update_in_chunks(digest, io)
|
281
|
+
loop do
|
282
|
+
chunk = io.read(CHUNK_SIZE)
|
283
|
+
break unless chunk
|
284
|
+
digest.update(chunk)
|
285
|
+
end
|
286
|
+
io.rewind
|
287
|
+
end
|
288
|
+
|
289
|
+
# Wrapper for request body that implements application-layer
|
290
|
+
# chunking with Digest computed on chunks + added as a trailer
|
291
|
+
class AwsChunkedTrailerDigestIO
|
292
|
+
CHUNK_SIZE = 16384
|
293
|
+
|
294
|
+
def initialize(io, algorithm, location_name)
|
295
|
+
@io = io
|
296
|
+
@location_name = location_name
|
297
|
+
@algorithm = algorithm
|
298
|
+
@digest = ChecksumAlgorithm.digest_for_algorithm(algorithm)
|
299
|
+
@trailer_io = nil
|
300
|
+
end
|
301
|
+
|
302
|
+
# the size of the application layer aws-chunked + trailer body
|
303
|
+
def size
|
304
|
+
# compute the number of chunks
|
305
|
+
# a full chunk has 4 + 4 bytes overhead, a partial chunk is len.to_s(16).size + 4
|
306
|
+
orig_body_size = @io.size
|
307
|
+
n_full_chunks = orig_body_size / CHUNK_SIZE
|
308
|
+
partial_bytes = orig_body_size % CHUNK_SIZE
|
309
|
+
chunked_body_size = n_full_chunks * (CHUNK_SIZE + 8)
|
310
|
+
chunked_body_size += partial_bytes.to_s(16).size + partial_bytes + 4 unless partial_bytes.zero?
|
311
|
+
trailer_size = ChecksumAlgorithm.trailer_length(@algorithm, @location_name)
|
312
|
+
chunked_body_size + trailer_size
|
313
|
+
end
|
314
|
+
|
315
|
+
def rewind
|
316
|
+
@io.rewind
|
317
|
+
end
|
318
|
+
|
319
|
+
def read(length, buf = nil)
|
320
|
+
# account for possible leftover bytes at the end, if we have trailer bytes, send them
|
321
|
+
if @trailer_io
|
322
|
+
return @trailer_io.read(length, buf)
|
323
|
+
end
|
324
|
+
|
325
|
+
chunk = @io.read(length)
|
326
|
+
if chunk
|
327
|
+
@digest.update(chunk)
|
328
|
+
application_chunked = "#{chunk.bytesize.to_s(16)}\r\n#{chunk}\r\n"
|
329
|
+
return StringIO.new(application_chunked).read(application_chunked.size, buf)
|
330
|
+
else
|
331
|
+
trailers = {}
|
332
|
+
trailers[@location_name] = @digest.base64digest
|
333
|
+
trailers = trailers.map { |k,v| "#{k}:#{v}"}.join("\r\n")
|
334
|
+
@trailer_io = StringIO.new("0\r\n#{trailers}\r\n\r\n")
|
335
|
+
chunk = @trailer_io.read(length, buf)
|
336
|
+
end
|
337
|
+
chunk
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
require_relative 'retries/error_inspector'
|
3
5
|
|
@@ -38,6 +40,7 @@ side monitoring agent is running on, where client metrics will be published via
|
|
38
40
|
option(:client_side_monitoring_publisher,
|
39
41
|
default: ClientSideMonitoring::Publisher,
|
40
42
|
doc_type: Aws::ClientSideMonitoring::Publisher,
|
43
|
+
rbs_type: 'untyped',
|
41
44
|
docstring: <<-DOCS) do |cfg|
|
42
45
|
Allows you to provide a custom client-side monitoring publisher class. By default,
|
43
46
|
will use the Client Side Monitoring Agent Publisher.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
# @api private
|
3
5
|
module Plugins
|
@@ -21,6 +23,7 @@ at HOME/.aws/credentials. When not specified, 'default' is used.
|
|
21
23
|
option(:credentials,
|
22
24
|
required: true,
|
23
25
|
doc_type: 'Aws::CredentialProvider',
|
26
|
+
rbs_type: 'untyped',
|
24
27
|
docstring: <<-DOCS
|
25
28
|
Your AWS credentials. This can be an instance of any one of the
|
26
29
|
following classes:
|
@@ -28,13 +31,28 @@ following classes:
|
|
28
31
|
* `Aws::Credentials` - Used for configuring static, non-refreshing
|
29
32
|
credentials.
|
30
33
|
|
34
|
+
* `Aws::SharedCredentials` - Used for loading static credentials from a
|
35
|
+
shared file, such as `~/.aws/config`.
|
36
|
+
|
37
|
+
* `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
|
38
|
+
|
39
|
+
* `Aws::AssumeRoleWebIdentityCredentials` - Used when you need to
|
40
|
+
assume a role after providing credentials via the web.
|
41
|
+
|
42
|
+
* `Aws::SSOCredentials` - Used for loading credentials from AWS SSO using an
|
43
|
+
access token generated from `aws login`.
|
44
|
+
|
45
|
+
* `Aws::ProcessCredentials` - Used for loading credentials from a
|
46
|
+
process that outputs to stdout.
|
47
|
+
|
31
48
|
* `Aws::InstanceProfileCredentials` - Used for loading credentials
|
32
49
|
from an EC2 IMDS on an EC2 instance.
|
33
50
|
|
34
|
-
* `Aws::
|
35
|
-
|
51
|
+
* `Aws::ECSCredentials` - Used for loading credentials from
|
52
|
+
instances running in ECS.
|
36
53
|
|
37
|
-
* `Aws::
|
54
|
+
* `Aws::CognitoIdentityCredentials` - Used for loading credentials
|
55
|
+
from the Cognito Identity service.
|
38
56
|
|
39
57
|
When `:credentials` are not configured directly, the following
|
40
58
|
locations will be searched for credentials:
|
@@ -44,10 +62,12 @@ locations will be searched for credentials:
|
|
44
62
|
* ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
|
45
63
|
* `~/.aws/credentials`
|
46
64
|
* `~/.aws/config`
|
47
|
-
* EC2 IMDS instance profile - When used by default, the timeouts
|
48
|
-
very aggressive. Construct and pass an instance of
|
49
|
-
`Aws::InstanceProfileCredentails`
|
50
|
-
timeouts.
|
65
|
+
* EC2/ECS IMDS instance profile - When used by default, the timeouts
|
66
|
+
are very aggressive. Construct and pass an instance of
|
67
|
+
`Aws::InstanceProfileCredentails` or `Aws::ECSCredentials` to
|
68
|
+
enable retries and extended timeouts. Instance profile credential
|
69
|
+
fetching can be disabled by setting ENV['AWS_EC2_METADATA_DISABLED']
|
70
|
+
to true.
|
51
71
|
DOCS
|
52
72
|
) do |config|
|
53
73
|
CredentialProviderChain.new(config).resolve
|
@@ -57,6 +77,31 @@ locations will be searched for credentials:
|
|
57
77
|
|
58
78
|
option(:instance_profile_credentials_timeout, 1)
|
59
79
|
|
80
|
+
option(:token_provider,
|
81
|
+
required: false,
|
82
|
+
doc_type: 'Aws::TokenProvider',
|
83
|
+
rbs_type: 'untyped',
|
84
|
+
docstring: <<-DOCS
|
85
|
+
A Bearer Token Provider. This can be an instance of any one of the
|
86
|
+
following classes:
|
87
|
+
|
88
|
+
* `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
|
89
|
+
tokens.
|
90
|
+
|
91
|
+
* `Aws::SSOTokenProvider` - Used for loading tokens from AWS SSO using an
|
92
|
+
access token generated from `aws login`.
|
93
|
+
|
94
|
+
When `:token_provider` is not configured directly, the `Aws::TokenProviderChain`
|
95
|
+
will be used to search for tokens configured for your profile in shared configuration files.
|
96
|
+
DOCS
|
97
|
+
) do |config|
|
98
|
+
if config.stub_responses
|
99
|
+
StaticTokenProvider.new('token')
|
100
|
+
else
|
101
|
+
TokenProviderChain.new(config).resolve
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
60
105
|
end
|
61
106
|
end
|
62
107
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
# @api private
|
5
|
+
module Plugins
|
6
|
+
# @api private
|
7
|
+
class DefaultsMode < Seahorse::Client::Plugin
|
8
|
+
|
9
|
+
option(:defaults_mode,
|
10
|
+
default: 'legacy',
|
11
|
+
doc_type: String,
|
12
|
+
docstring: <<-DOCS
|
13
|
+
See {Aws::DefaultsModeConfiguration} for a list of the
|
14
|
+
accepted modes and the configuration defaults that are included.
|
15
|
+
DOCS
|
16
|
+
) do |cfg|
|
17
|
+
resolve_defaults_mode(cfg)
|
18
|
+
end
|
19
|
+
|
20
|
+
option(:defaults_mode_config_resolver,
|
21
|
+
doc_type: 'Aws::DefaultsModeConfigResolver') do |cfg|
|
22
|
+
Aws::DefaultsModeConfigResolver.new(
|
23
|
+
Aws::DefaultsModeConfiguration::SDK_DEFAULT_CONFIGURATION, cfg)
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
private
|
28
|
+
|
29
|
+
def resolve_defaults_mode(cfg)
|
30
|
+
value = ENV['AWS_DEFAULTS_MODE']
|
31
|
+
value ||= Aws.shared_config.defaults_mode(
|
32
|
+
profile: cfg.profile
|
33
|
+
)
|
34
|
+
value&.downcase || "legacy"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
module Plugins
|
3
5
|
# @api private
|
@@ -70,7 +72,11 @@ the background every 60 secs (default). Defaults to `false`.
|
|
70
72
|
context,
|
71
73
|
Aws::Util.str_2_bool(discovery_cfg["required"])
|
72
74
|
)
|
73
|
-
|
75
|
+
if endpoint
|
76
|
+
context.http_request.endpoint = _valid_uri(endpoint.address)
|
77
|
+
# Skips dynamic endpoint usage, use this endpoint instead
|
78
|
+
context[:discovered_endpoint] = true
|
79
|
+
end
|
74
80
|
if endpoint || context.config.endpoint_discovery
|
75
81
|
_apply_endpoint_discovery_user_agent(context)
|
76
82
|
end
|
@@ -98,7 +104,7 @@ the background every 60 secs (default). Defaults to `false`.
|
|
98
104
|
end
|
99
105
|
|
100
106
|
def _discover_endpoint(ctx, required)
|
101
|
-
cache = ctx.config.endpoint_cache
|
107
|
+
cache = ctx.config.endpoint_cache
|
102
108
|
key = cache.extract_key(ctx)
|
103
109
|
|
104
110
|
if required
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
module Plugins
|
3
5
|
# @api private
|
@@ -13,17 +15,17 @@ to default service endpoint when available.
|
|
13
15
|
)
|
14
16
|
|
15
17
|
def add_handlers(handlers, config)
|
16
|
-
|
17
|
-
handlers.add(Handler, priority: 90)
|
18
|
-
end
|
18
|
+
handlers.add(Handler, priority: 10)
|
19
19
|
end
|
20
20
|
|
21
21
|
class Handler < Seahorse::Client::Handler
|
22
22
|
|
23
23
|
def call(context)
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
if !context.config.disable_host_prefix_injection
|
25
|
+
endpoint_trait = context.operation.endpoint_pattern
|
26
|
+
if endpoint_trait && !endpoint_trait.empty?
|
27
|
+
_apply_endpoint_trait(context, endpoint_trait)
|
28
|
+
end
|
27
29
|
end
|
28
30
|
@handler.call(context)
|
29
31
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'openssl'
|
2
4
|
|
3
5
|
module Aws
|
@@ -9,7 +11,9 @@ module Aws
|
|
9
11
|
CHUNK_SIZE = 1 * 1024 * 1024 # one MB
|
10
12
|
|
11
13
|
def call(context)
|
12
|
-
if context
|
14
|
+
if checksum_required?(context) &&
|
15
|
+
!context[:checksum_algorithms] && # skip in favor of flexible checksum
|
16
|
+
!context[:s3_express_endpoint] # s3 express endpoints do not support md5
|
13
17
|
body = context.http_request.body
|
14
18
|
context.http_request.headers['Content-Md5'] ||= md5(body)
|
15
19
|
end
|
@@ -18,6 +22,12 @@ module Aws
|
|
18
22
|
|
19
23
|
private
|
20
24
|
|
25
|
+
def checksum_required?(context)
|
26
|
+
context.operation.http_checksum_required ||
|
27
|
+
(context.operation.http_checksum &&
|
28
|
+
context.operation.http_checksum['requestChecksumRequired'])
|
29
|
+
end
|
30
|
+
|
21
31
|
# @param [File, Tempfile, IO#read, String] value
|
22
32
|
# @return [String<MD5>]
|
23
33
|
def md5(value)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
module Plugins
|
3
5
|
|
@@ -9,15 +11,43 @@ module Aws
|
|
9
11
|
|
10
12
|
def call(context)
|
11
13
|
context.operation.input.shape.members.each do |m, ref|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
convert_jsonvalue(m, ref, context.params, 'params')
|
15
|
+
end
|
16
|
+
@handler.call(context)
|
17
|
+
end
|
18
|
+
|
19
|
+
def convert_jsonvalue(m, ref, params, context)
|
20
|
+
return if params.nil? || !params.key?(m)
|
21
|
+
|
22
|
+
if ref['jsonvalue']
|
23
|
+
params[m] = serialize_jsonvalue(params[m], "#{context}[#{m}]")
|
24
|
+
else
|
25
|
+
case ref.shape
|
26
|
+
when Seahorse::Model::Shapes::StructureShape
|
27
|
+
ref.shape.members.each do |member_m, ref|
|
28
|
+
convert_jsonvalue(member_m, ref, params[m], "#{context}[#{m}]")
|
29
|
+
end
|
30
|
+
when Seahorse::Model::Shapes::ListShape
|
31
|
+
if ref.shape.member['jsonvalue']
|
32
|
+
params[m] = params[m].each_with_index.map do |v, i|
|
33
|
+
serialize_jsonvalue(v, "#{context}[#{m}][#{i}]")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
when Seahorse::Model::Shapes::MapShape
|
37
|
+
if ref.shape.value['jsonvalue']
|
38
|
+
params[m].each do |k, v|
|
39
|
+
params[m][k] = serialize_jsonvalue(v, "#{context}[#{m}][#{k}]")
|
40
|
+
end
|
16
41
|
end
|
17
|
-
context.params[m] = param_value.to_json
|
18
42
|
end
|
19
43
|
end
|
20
|
-
|
44
|
+
end
|
45
|
+
|
46
|
+
def serialize_jsonvalue(v, context)
|
47
|
+
unless v.respond_to?(:to_json)
|
48
|
+
raise ArgumentError, "The value of #{context} is not JSON serializable."
|
49
|
+
end
|
50
|
+
v.to_json
|
21
51
|
end
|
22
52
|
|
23
53
|
end
|