aws-sdk-core 3.124.0 → 3.186.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 +552 -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 +13 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +21 -7
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +14 -10
- data/lib/aws-sdk-core/binary/encode_handler.rb +12 -1
- data/lib/aws-sdk-core/client_stubs.rb +5 -1
- data/lib/aws-sdk-core/credential_provider.rb +3 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
- data/lib/aws-sdk-core/ec2_metadata.rb +3 -2
- data/lib/aws-sdk-core/ecs_credentials.rb +121 -53
- 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 +15 -2
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +124 -31
- data/lib/aws-sdk-core/json/error_handler.rb +20 -1
- data/lib/aws-sdk-core/json/parser.rb +1 -1
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/pageable_response.rb +81 -32
- data/lib/aws-sdk-core/param_validator.rb +2 -2
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +340 -0
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +24 -0
- data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +6 -2
- data/lib/aws-sdk-core/plugins/http_checksum.rb +8 -1
- data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +34 -6
- data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +111 -30
- data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
- data/lib/aws-sdk-core/plugins/response_paging.rb +1 -1
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +7 -4
- data/lib/aws-sdk-core/plugins/retry_errors.rb +21 -5
- data/lib/aws-sdk-core/plugins/sign.rb +201 -0
- data/lib/aws-sdk-core/plugins/signature_v2.rb +1 -0
- data/lib/aws-sdk-core/plugins/signature_v4.rb +15 -8
- data/lib/aws-sdk-core/plugins/stub_responses.rb +5 -1
- data/lib/aws-sdk-core/plugins/user_agent.rb +117 -14
- data/lib/aws-sdk-core/process_credentials.rb +9 -11
- data/lib/aws-sdk-core/refreshing_credentials.rb +41 -16
- data/lib/aws-sdk-core/refreshing_token.rb +71 -0
- data/lib/aws-sdk-core/rest/handler.rb +1 -1
- data/lib/aws-sdk-core/rest/request/headers.rb +11 -8
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +43 -29
- data/lib/aws-sdk-core/shared_config.rb +108 -12
- data/lib/aws-sdk-core/sso_credentials.rb +91 -50
- 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 +6 -4
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -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/waiters/poller.rb +3 -1
- data/lib/aws-sdk-core/xml/error_handler.rb +7 -0
- data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/ox.rb +1 -1
- data/lib/aws-sdk-core.rb +17 -0
- data/lib/aws-sdk-sso/client.rb +85 -12
- 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/plugins/endpoints.rb +76 -0
- data/lib/aws-sdk-sso/types.rb +8 -43
- data/lib/aws-sdk-sso.rb +5 -1
- data/lib/aws-sdk-ssooidc/client.rb +626 -0
- data/lib/aws-sdk-ssooidc/client_api.rb +216 -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 +58 -0
- data/lib/aws-sdk-ssooidc/errors.rb +290 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +74 -0
- data/lib/aws-sdk-ssooidc/resource.rb +26 -0
- data/lib/aws-sdk-ssooidc/types.rb +502 -0
- data/lib/aws-sdk-ssooidc.rb +59 -0
- data/lib/aws-sdk-sts/client.rb +332 -263
- data/lib/aws-sdk-sts/client_api.rb +12 -1
- 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/plugins/endpoints.rb +84 -0
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +5 -1
- data/lib/aws-sdk-sts/presigner.rb +13 -15
- data/lib/aws-sdk-sts/types.rb +121 -204
- data/lib/aws-sdk-sts.rb +5 -1
- data/lib/seahorse/client/async_base.rb +0 -1
- data/lib/seahorse/client/configuration.rb +1 -5
- data/lib/seahorse/client/h2/connection.rb +12 -11
- data/lib/seahorse/client/net_http/connection_pool.rb +7 -0
- data/lib/seahorse/client/plugins/net_http.rb +33 -2
- data/lib/seahorse/client/plugins/request_callback.rb +40 -9
- data/lib/seahorse/client/response.rb +6 -0
- data/lib/seahorse/model/operation.rb +6 -0
- data/lib/seahorse/util.rb +4 -0
- metadata +62 -8
@@ -0,0 +1,153 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'defaults_mode_config_resolver'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
|
7
|
+
# A defaults mode determines how certain default configuration options are resolved in the SDK.
|
8
|
+
#
|
9
|
+
# *Note*: For any mode other than `'legacy'` the vended default values might change as best practices may
|
10
|
+
# evolve. As a result, it is encouraged to perform testing when upgrading the SDK if you are using a mode other than
|
11
|
+
# `'legacy'`. While the `'legacy'` defaults mode is specific to Ruby,
|
12
|
+
# other modes are standardized across all of the AWS SDKs.
|
13
|
+
#
|
14
|
+
# The defaults mode can be configured:
|
15
|
+
#
|
16
|
+
# * Directly on a client via `:defaults_mode`
|
17
|
+
#
|
18
|
+
# * On a configuration profile via the "defaults_mode" profile file property.
|
19
|
+
#
|
20
|
+
# * Globally via the "AWS_DEFAULTS_MODE" environment variable.
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# #defaults START - documentation
|
24
|
+
# The following `:default_mode` values are supported:
|
25
|
+
#
|
26
|
+
# * `'standard'` -
|
27
|
+
# The STANDARD mode provides the latest recommended default values
|
28
|
+
# that should be safe to run in most scenarios
|
29
|
+
#
|
30
|
+
# Note that the default values vended from this mode might change as
|
31
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
32
|
+
# tests when upgrading the SDK
|
33
|
+
#
|
34
|
+
# * `'in-region'` -
|
35
|
+
# The IN\_REGION mode builds on the standard mode and includes
|
36
|
+
# optimization tailored for applications which call AWS services from
|
37
|
+
# within the same AWS region
|
38
|
+
#
|
39
|
+
# Note that the default values vended from this mode might change as
|
40
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
41
|
+
# tests when upgrading the SDK
|
42
|
+
#
|
43
|
+
# * `'cross-region'` -
|
44
|
+
# The CROSS\_REGION mode builds on the standard mode and includes
|
45
|
+
# optimization tailored for applications which call AWS services in a
|
46
|
+
# different region
|
47
|
+
#
|
48
|
+
# Note that the default values vended from this mode might change as
|
49
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
50
|
+
# tests when upgrading the SDK
|
51
|
+
#
|
52
|
+
# * `'mobile'` -
|
53
|
+
# The MOBILE mode builds on the standard mode and includes
|
54
|
+
# optimization tailored for mobile applications
|
55
|
+
#
|
56
|
+
# Note that the default values vended from this mode might change as
|
57
|
+
# best practices may evolve. As a result, it is encouraged to perform
|
58
|
+
# tests when upgrading the SDK
|
59
|
+
#
|
60
|
+
# * `'auto'` -
|
61
|
+
# The AUTO mode is an experimental mode that builds on the standard
|
62
|
+
# mode. The SDK will attempt to discover the execution environment to
|
63
|
+
# determine the appropriate settings automatically.
|
64
|
+
#
|
65
|
+
# Note that the auto detection is heuristics-based and does not
|
66
|
+
# guarantee 100% accuracy. STANDARD mode will be used if the execution
|
67
|
+
# environment cannot be determined. The auto detection might query
|
68
|
+
# [EC2 Instance Metadata service][1], which might introduce latency.
|
69
|
+
# Therefore we recommend choosing an explicit defaults\_mode instead
|
70
|
+
# if startup latency is critical to your application
|
71
|
+
#
|
72
|
+
# * `'legacy'` -
|
73
|
+
# The LEGACY mode provides default settings that vary per SDK and were
|
74
|
+
# used prior to establishment of defaults\_mode
|
75
|
+
#
|
76
|
+
# Based on the provided mode, the SDK will vend sensible default values
|
77
|
+
# tailored to the mode for the following settings:
|
78
|
+
#
|
79
|
+
# * `:retry_mode` -
|
80
|
+
# A retry mode specifies how the SDK attempts retries. See [Retry
|
81
|
+
# Mode][2]
|
82
|
+
#
|
83
|
+
# * `:sts_regional_endpoints` -
|
84
|
+
# Specifies how the SDK determines the AWS service endpoint that it
|
85
|
+
# uses to talk to the AWS Security Token Service (AWS STS). See
|
86
|
+
# [Setting STS Regional endpoints][3]
|
87
|
+
#
|
88
|
+
# * `:s3_us_east_1_regional_endpoint` -
|
89
|
+
# Specifies how the SDK determines the AWS service endpoint that it
|
90
|
+
# uses to talk to the Amazon S3 for the us-east-1 region
|
91
|
+
#
|
92
|
+
# * `:http_open_timeout` -
|
93
|
+
# The amount of time after making an initial connection attempt on a
|
94
|
+
# socket, where if the client does not receive a completion of the
|
95
|
+
# connect handshake, the client gives up and fails the operation
|
96
|
+
#
|
97
|
+
# * `:ssl_timeout` -
|
98
|
+
# The maximum amount of time that a TLS handshake is allowed to take
|
99
|
+
# from the time the CLIENT HELLO message is sent to ethe time the
|
100
|
+
# client and server have fully negotiated ciphers and exchanged keys
|
101
|
+
#
|
102
|
+
# All options above can be configured by users, and the overridden value will take precedence.
|
103
|
+
#
|
104
|
+
# [1]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
|
105
|
+
# [2]: https://docs.aws.amazon.com/sdkref/latest/guide/setting-global-retry_mode.html
|
106
|
+
# [3]: https://docs.aws.amazon.com/sdkref/latest/guide/setting-global-sts_regional_endpoints.html
|
107
|
+
#
|
108
|
+
# #defaults END - documentation
|
109
|
+
module DefaultsModeConfiguration
|
110
|
+
# @api private
|
111
|
+
# #defaults START - configuration
|
112
|
+
SDK_DEFAULT_CONFIGURATION =
|
113
|
+
{
|
114
|
+
"version" => 1,
|
115
|
+
"base" => {
|
116
|
+
"retryMode" => "standard",
|
117
|
+
"stsRegionalEndpoints" => "regional",
|
118
|
+
"s3UsEast1RegionalEndpoints" => "regional",
|
119
|
+
"connectTimeoutInMillis" => 1100,
|
120
|
+
"tlsNegotiationTimeoutInMillis" => 1100
|
121
|
+
},
|
122
|
+
"modes" => {
|
123
|
+
"standard" => {
|
124
|
+
"connectTimeoutInMillis" => {
|
125
|
+
"override" => 3100
|
126
|
+
},
|
127
|
+
"tlsNegotiationTimeoutInMillis" => {
|
128
|
+
"override" => 3100
|
129
|
+
}
|
130
|
+
},
|
131
|
+
"in-region" => {
|
132
|
+
},
|
133
|
+
"cross-region" => {
|
134
|
+
"connectTimeoutInMillis" => {
|
135
|
+
"override" => 3100
|
136
|
+
},
|
137
|
+
"tlsNegotiationTimeoutInMillis" => {
|
138
|
+
"override" => 3100
|
139
|
+
}
|
140
|
+
},
|
141
|
+
"mobile" => {
|
142
|
+
"connectTimeoutInMillis" => {
|
143
|
+
"override" => 30000
|
144
|
+
},
|
145
|
+
"tlsNegotiationTimeoutInMillis" => {
|
146
|
+
"override" => 30000
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
# #defaults END - configuration
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
#@api private
|
5
|
+
class DefaultsModeConfigResolver
|
6
|
+
|
7
|
+
@@application_region = nil
|
8
|
+
@@application_region_mutex = Mutex.new
|
9
|
+
@@imds_client = EC2Metadata.new(retries: 0, http_open_timeout: 0.01)
|
10
|
+
|
11
|
+
# mappings from Ruby SDK configuration names to the
|
12
|
+
# sdk defaults option names and (optional) scale modifiers
|
13
|
+
CFG_OPTIONS = {
|
14
|
+
retry_mode: { name: "retryMode" },
|
15
|
+
sts_regional_endpoints: { name: "stsRegionalEndpoints" },
|
16
|
+
s3_us_east_1_regional_endpoint: { name: "s3UsEast1RegionalEndpoints" },
|
17
|
+
http_open_timeout: { name: "connectTimeoutInMillis", scale: 0.001 },
|
18
|
+
http_read_timeout: { name: "timeToFirstByteTimeoutInMillis", scale: 0.001 },
|
19
|
+
ssl_timeout: { name: "tlsNegotiationTimeoutInMillis", scale: 0.001 }
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
def initialize(sdk_defaults, cfg)
|
23
|
+
@sdk_defaults = sdk_defaults
|
24
|
+
@cfg = cfg
|
25
|
+
@resolved_mode = nil
|
26
|
+
@mutex = Mutex.new
|
27
|
+
end
|
28
|
+
|
29
|
+
# option_name should be the symbolized ruby name to resolve
|
30
|
+
# returns the ruby appropriate value or nil if none are resolved
|
31
|
+
def resolve(option_name)
|
32
|
+
return unless (std_option = CFG_OPTIONS[option_name])
|
33
|
+
mode = resolved_mode.downcase
|
34
|
+
|
35
|
+
return nil if mode == 'legacy'
|
36
|
+
|
37
|
+
value = resolve_for_mode(std_option[:name], mode)
|
38
|
+
value = value * std_option[:scale] if value && std_option[:scale]
|
39
|
+
|
40
|
+
value
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def resolved_mode
|
45
|
+
@mutex.synchronize do
|
46
|
+
return @resolved_mode unless @resolved_mode.nil?
|
47
|
+
|
48
|
+
@resolved_mode = @cfg.defaults_mode == 'auto' ? resolve_auto_mode : @cfg.defaults_mode
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def resolve_auto_mode
|
53
|
+
return "mobile" if env_mobile?
|
54
|
+
|
55
|
+
region = application_current_region
|
56
|
+
|
57
|
+
if region
|
58
|
+
@cfg.region == region ? "in-region": "cross-region"
|
59
|
+
else
|
60
|
+
# We don't seem to be mobile, and we couldn't determine whether we're running within an AWS region. Fall back to standard.
|
61
|
+
'standard'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def application_current_region
|
66
|
+
resolved_region = @@application_region_mutex.synchronize do
|
67
|
+
return @@application_region unless @@application_region.nil?
|
68
|
+
|
69
|
+
region = nil
|
70
|
+
if ENV['AWS_EXECUTION_ENV']
|
71
|
+
region = ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION']
|
72
|
+
end
|
73
|
+
|
74
|
+
if region.nil? && ENV['AWS_EC2_METADATA_DISABLED']&.downcase != "true"
|
75
|
+
begin
|
76
|
+
region = @@imds_client.get('/latest/meta-data/placement/region')
|
77
|
+
rescue
|
78
|
+
# unable to get region, leave it unset
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# required so that we cache the unknown/nil result
|
83
|
+
@@application_region = region || :unknown
|
84
|
+
end
|
85
|
+
resolved_region == :unknown ? nil : resolved_region
|
86
|
+
end
|
87
|
+
|
88
|
+
def resolve_for_mode(name, mode)
|
89
|
+
base_value = @sdk_defaults['base'][name]
|
90
|
+
mode_value = @sdk_defaults['modes'].fetch(mode, {})[name]
|
91
|
+
|
92
|
+
if mode_value.nil?
|
93
|
+
return base_value
|
94
|
+
end
|
95
|
+
|
96
|
+
return mode_value['override'] unless mode_value['override'].nil?
|
97
|
+
return base_value + mode_value['add'] unless mode_value['add'].nil?
|
98
|
+
return base_value * mode_value['multiply'] unless mode_value['multiply'].nil?
|
99
|
+
return base_value
|
100
|
+
end
|
101
|
+
|
102
|
+
def env_mobile?
|
103
|
+
false
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
data/lib/aws-defaults.rb
ADDED
data/lib/aws-sdk-core/arn.rb
CHANGED
@@ -88,5 +88,18 @@ module Aws
|
|
88
88
|
resource: @resource
|
89
89
|
}
|
90
90
|
end
|
91
|
+
|
92
|
+
# Return the ARN as JSON
|
93
|
+
#
|
94
|
+
# @return [Hash]
|
95
|
+
def as_json(_options = nil)
|
96
|
+
{
|
97
|
+
'partition' => @partition,
|
98
|
+
'service' => @service,
|
99
|
+
'region' => @region,
|
100
|
+
'accountId' => @account_id,
|
101
|
+
'resource' => @resource
|
102
|
+
}
|
103
|
+
end
|
91
104
|
end
|
92
105
|
end
|
@@ -3,20 +3,20 @@
|
|
3
3
|
require 'set'
|
4
4
|
|
5
5
|
module Aws
|
6
|
-
|
7
|
-
#
|
8
|
-
# a role via {Aws::STS::Client#assume_role}.
|
6
|
+
# An auto-refreshing credential provider that assumes a role via
|
7
|
+
# {Aws::STS::Client#assume_role}.
|
9
8
|
#
|
10
9
|
# role_credentials = Aws::AssumeRoleCredentials.new(
|
11
10
|
# client: Aws::STS::Client.new(...),
|
12
11
|
# role_arn: "linked::account::arn",
|
13
12
|
# role_session_name: "session-name"
|
14
13
|
# )
|
15
|
-
#
|
16
14
|
# ec2 = Aws::EC2::Client.new(credentials: role_credentials)
|
17
15
|
#
|
18
|
-
# If you omit `:client` option, a new {STS::Client} object will be
|
19
|
-
# constructed.
|
16
|
+
# If you omit `:client` option, a new {Aws::STS::Client} object will be
|
17
|
+
# constructed with additional options that were provided.
|
18
|
+
#
|
19
|
+
# @see Aws::STS::Client#assume_role
|
20
20
|
class AssumeRoleCredentials
|
21
21
|
|
22
22
|
include CredentialProvider
|
@@ -28,23 +28,37 @@ 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
|
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:
|
36
|
+
#
|
37
|
+
# before_refresh = Proc.new do |assume_role_credentials| do
|
38
|
+
# assume_role_credentials.assume_role_params['token_code'] = update_token
|
39
|
+
# end
|
40
|
+
#
|
31
41
|
def initialize(options = {})
|
32
42
|
client_opts = {}
|
33
43
|
@assume_role_params = {}
|
34
44
|
options.each_pair do |key, value|
|
35
45
|
if self.class.assume_role_options.include?(key)
|
36
46
|
@assume_role_params[key] = value
|
37
|
-
|
47
|
+
elsif !CLIENT_EXCLUDE_OPTIONS.include?(key)
|
38
48
|
client_opts[key] = value
|
39
49
|
end
|
40
50
|
end
|
41
51
|
@client = client_opts[:client] || STS::Client.new(client_opts)
|
52
|
+
@async_refresh = true
|
42
53
|
super
|
43
54
|
end
|
44
55
|
|
45
56
|
# @return [STS::Client]
|
46
57
|
attr_reader :client
|
47
58
|
|
59
|
+
# @return [Hash]
|
60
|
+
attr_reader :assume_role_params
|
61
|
+
|
48
62
|
private
|
49
63
|
|
50
64
|
def refresh
|
@@ -5,9 +5,8 @@ require 'securerandom'
|
|
5
5
|
require 'base64'
|
6
6
|
|
7
7
|
module Aws
|
8
|
-
|
9
|
-
#
|
10
|
-
# a role via {Aws::STS::Client#assume_role_with_web_identity}.
|
8
|
+
# An auto-refreshing credential provider that assumes a role via
|
9
|
+
# {Aws::STS::Client#assume_role_with_web_identity}.
|
11
10
|
#
|
12
11
|
# role_credentials = Aws::AssumeRoleWebIdentityCredentials.new(
|
13
12
|
# client: Aws::STS::Client.new(...),
|
@@ -16,12 +15,12 @@ module Aws
|
|
16
15
|
# role_session_name: "session-name"
|
17
16
|
# ...
|
18
17
|
# )
|
19
|
-
#
|
20
|
-
# @see Aws::STS::Client#assume_role_with_web_identity
|
18
|
+
# ec2 = Aws::EC2::Client.new(credentials: role_credentials)
|
21
19
|
#
|
20
|
+
# If you omit `:client` option, a new {Aws::STS::Client} object will be
|
21
|
+
# constructed with additional options that were provided.
|
22
22
|
#
|
23
|
-
#
|
24
|
-
# constructed.
|
23
|
+
# @see Aws::STS::Client#assume_role_with_web_identity
|
25
24
|
class AssumeRoleWebIdentityCredentials
|
26
25
|
|
27
26
|
include CredentialProvider
|
@@ -39,14 +38,20 @@ module Aws
|
|
39
38
|
# encoded UUID is generated as the session name
|
40
39
|
#
|
41
40
|
# @option options [STS::Client] :client
|
41
|
+
#
|
42
|
+
# @option options [Callable] before_refresh Proc called before
|
43
|
+
# credentials are refreshed. `before_refresh` is called
|
44
|
+
# with an instance of this object when
|
45
|
+
# AWS credentials are required and need to be refreshed.
|
42
46
|
def initialize(options = {})
|
43
47
|
client_opts = {}
|
44
48
|
@assume_role_web_identity_params = {}
|
45
49
|
@token_file = options.delete(:web_identity_token_file)
|
50
|
+
@async_refresh = true
|
46
51
|
options.each_pair do |key, value|
|
47
52
|
if self.class.assume_role_web_identity_options.include?(key)
|
48
53
|
@assume_role_web_identity_params[key] = value
|
49
|
-
|
54
|
+
elsif !CLIENT_EXCLUDE_OPTIONS.include?(key)
|
50
55
|
client_opts[key] = value
|
51
56
|
end
|
52
57
|
end
|
@@ -94,11 +99,10 @@ module Aws
|
|
94
99
|
# @api private
|
95
100
|
def assume_role_web_identity_options
|
96
101
|
@arwio ||= begin
|
97
|
-
input = STS::Client.api.operation(:assume_role_with_web_identity).input
|
102
|
+
input = Aws::STS::Client.api.operation(:assume_role_with_web_identity).input
|
98
103
|
Set.new(input.shape.member_names)
|
99
104
|
end
|
100
105
|
end
|
101
|
-
|
102
106
|
end
|
103
107
|
end
|
104
108
|
end
|
@@ -13,7 +13,7 @@ module Aws
|
|
13
13
|
context.config.api.metadata['protocol'],
|
14
14
|
eventstream_member,
|
15
15
|
context.operation.input,
|
16
|
-
context
|
16
|
+
signer_for(context)
|
17
17
|
)
|
18
18
|
context[:input_event_emitter] = input_es_handler.event_emitter
|
19
19
|
end
|
@@ -22,6 +22,17 @@ module Aws
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
+
def signer_for(context)
|
26
|
+
# New endpoint/signing logic, use the auth scheme to make a signer
|
27
|
+
if context[:auth_scheme]
|
28
|
+
Aws::Plugins::Sign.signer_for(context[:auth_scheme], context.config)
|
29
|
+
else
|
30
|
+
# Previous implementation always assumed sigv4_signer from config.
|
31
|
+
# Relies only on sigv4 signing (and plugin) for event stream services
|
32
|
+
context.config.sigv4_signer
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
def eventstream_input?(ctx)
|
26
37
|
ctx.operation.input.shape.members.each do |_, ref|
|
27
38
|
return ref if ref.eventstream
|
@@ -262,13 +262,17 @@ module Aws
|
|
262
262
|
end
|
263
263
|
|
264
264
|
def convert_stub(operation_name, stub)
|
265
|
-
case stub
|
265
|
+
stub = case stub
|
266
266
|
when Proc then stub
|
267
267
|
when Exception, Class then { error: stub }
|
268
268
|
when String then service_error_stub(stub)
|
269
269
|
when Hash then http_response_stub(operation_name, stub)
|
270
270
|
else { data: stub }
|
271
271
|
end
|
272
|
+
if Hash === stub
|
273
|
+
stub[:mutex] = Mutex.new
|
274
|
+
end
|
275
|
+
stub
|
272
276
|
end
|
273
277
|
|
274
278
|
def service_error_stub(error_code)
|
@@ -161,7 +161,8 @@ module Aws
|
|
161
161
|
|
162
162
|
def instance_profile_credentials(options)
|
163
163
|
profile_name = determine_profile_name(options)
|
164
|
-
if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
|
164
|
+
if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] ||
|
165
|
+
ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
|
165
166
|
ECSCredentials.new(options)
|
166
167
|
else
|
167
168
|
InstanceProfileCredentials.new(options.merge(profile: profile_name))
|
@@ -169,12 +170,14 @@ module Aws
|
|
169
170
|
end
|
170
171
|
|
171
172
|
def assume_role_with_profile(options, profile_name)
|
172
|
-
|
173
|
-
Aws.shared_config.assume_role_credentials_from_config(
|
173
|
+
assume_opts = {
|
174
174
|
profile: profile_name,
|
175
|
-
region: region,
|
176
175
|
chain_config: @config
|
177
|
-
|
176
|
+
}
|
177
|
+
if options[:config] && options[:config].region
|
178
|
+
assume_opts[:region] = options[:config].region
|
179
|
+
end
|
180
|
+
Aws.shared_config.assume_role_credentials_from_config(assume_opts)
|
178
181
|
end
|
179
182
|
end
|
180
183
|
end
|
@@ -136,8 +136,9 @@ module Aws
|
|
136
136
|
|
137
137
|
def fetch_token
|
138
138
|
open_connection do |conn|
|
139
|
+
created_time = Time.now
|
139
140
|
token_value, token_ttl = http_put(conn, @token_ttl)
|
140
|
-
@token = Token.new(value: token_value, ttl: token_ttl)
|
141
|
+
@token = Token.new(value: token_value, ttl: token_ttl, created_time: created_time)
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
@@ -222,7 +223,7 @@ module Aws
|
|
222
223
|
def initialize(options = {})
|
223
224
|
@ttl = options[:ttl]
|
224
225
|
@value = options[:value]
|
225
|
-
@created_time = Time.now
|
226
|
+
@created_time = options[:created_time] || Time.now
|
226
227
|
end
|
227
228
|
|
228
229
|
# [String] Returns the token value.
|