@@ -34,7 +34,7 @@ namespace Aws
34
34
35
35
namespace Auth
36
36
{
37
- /*
37
+ /* *
38
38
* A class to hold the basic components necessary for various AWS authentication protocols.
39
39
*/
40
40
class AWS_CRT_CPP_API Credentials
@@ -54,128 +54,185 @@ namespace Aws
54
54
Credentials &operator =(const Credentials &) = delete ;
55
55
Credentials &operator =(Credentials &&) = delete ;
56
56
57
+ /* *
58
+ * Gets the value of the access key component of aws credentials
59
+ */
57
60
ByteCursor GetAccessKeyId () const noexcept ;
58
61
62
+ /* *
63
+ * Gets the value of the secret access key component of aws credentials
64
+ */
59
65
ByteCursor GetSecretAccessKey () const noexcept ;
60
66
67
+ /* *
68
+ * Gets the value of the session token of aws credentials
69
+ */
61
70
ByteCursor GetSessionToken () const noexcept ;
62
71
63
- operator bool () const noexcept ;
72
+ /* *
73
+ * Validity check - returns true if the instance is valid, false otherwise
74
+ */
75
+ explicit operator bool () const noexcept ;
64
76
77
+ /* *
78
+ * Returns the underlying credentials implementation.
79
+ */
65
80
aws_credentials *GetUnderlyingHandle () const noexcept { return m_credentials; }
66
81
67
82
private:
68
83
aws_credentials *m_credentials;
69
84
};
70
85
71
- /*
86
+ /* *
72
87
* Callback invoked by credentials providers when resolution succeeds (credentials will be non-null)
73
88
* or fails (credentials will be null)
74
89
*/
75
90
using OnCredentialsResolved = std::function<void (std::shared_ptr<Credentials>)>;
76
91
77
- /*
92
+ /* *
78
93
* Base interface for all credentials providers. Credentials providers are objects that
79
- * retrieve (asynchronously) AWS credentials from some source.
94
+ * retrieve AWS credentials from some source.
80
95
*/
81
96
class AWS_CRT_CPP_API ICredentialsProvider : public std::enable_shared_from_this<ICredentialsProvider>
82
97
{
83
98
public:
84
99
virtual ~ICredentialsProvider () = default ;
85
100
86
- /*
101
+ /* *
87
102
* Asynchronous method to query for AWS credentials based on the internal provider implementation.
88
103
*/
89
104
virtual bool GetCredentials (const OnCredentialsResolved &onCredentialsResolved) const = 0;
90
105
91
- /*
106
+ /* *
92
107
* Returns the underlying credentials provider implementation. Support for credentials providers
93
108
* not based on a C implementation is theoretically possible, but requires some re-implementation to
94
109
* support provider chains and caching (whose implementations rely on links to C implementation
95
110
* providers)
96
111
*/
97
112
virtual aws_credentials_provider *GetUnderlyingHandle () const noexcept = 0;
98
113
99
- /*
100
- * Validity check
114
+ /* *
115
+ * Validity check method
101
116
*/
102
- virtual operator bool () const noexcept = 0;
117
+ virtual bool IsValid () const noexcept = 0;
103
118
};
104
119
105
- /*
120
+ /* *
106
121
* Configuration options for the static credentials provider
107
122
*/
108
123
struct AWS_CRT_CPP_API CredentialsProviderStaticConfig
109
124
{
110
- CredentialsProviderStaticConfig () : m_accessKeyId(), m_secretAccessKey(), m_sessionToken() {}
125
+ CredentialsProviderStaticConfig () : AccessKeyId{}, SecretAccessKey{}, SessionToken{} {}
126
+
127
+ /* *
128
+ * The value of the access key component for the provider's static aws credentials
129
+ */
130
+ ByteCursor AccessKeyId;
111
131
112
- ByteCursor m_accessKeyId;
113
- ByteCursor m_secretAccessKey;
114
- ByteCursor m_sessionToken;
132
+ /* *
133
+ * The value of the secret access key component for the provider's static aws credentials
134
+ */
135
+ ByteCursor SecretAccessKey;
136
+
137
+ /* *
138
+ * The value of the session token for the provider's static aws credentials
139
+ */
140
+ ByteCursor SessionToken;
115
141
};
116
142
117
- /*
143
+ /* *
118
144
* Configuration options for the profile credentials provider
119
145
*/
120
146
struct AWS_CRT_CPP_API CredentialsProviderProfileConfig
121
147
{
122
148
CredentialsProviderProfileConfig ()
123
- : m_profileNameOverride(), m_configFileNameOverride(), m_credentialsFileNameOverride()
149
+ : ProfileNameOverride{}, ConfigFileNameOverride{}, CredentialsFileNameOverride{}
124
150
{
125
151
}
126
152
127
- ByteCursor m_profileNameOverride;
128
- ByteCursor m_configFileNameOverride;
129
- ByteCursor m_credentialsFileNameOverride;
153
+ /* *
154
+ * Override profile name to use (instead of default) when the provider sources credentials
155
+ */
156
+ ByteCursor ProfileNameOverride;
157
+
158
+ /* *
159
+ * Override file path (instead of '~/.aws/config' for the aws config file to use during
160
+ * credential sourcing
161
+ */
162
+ ByteCursor ConfigFileNameOverride;
163
+
164
+ /* *
165
+ * Override file path (instead of '~/.aws/credentials' for the aws credentials file to use during
166
+ * credential sourcing
167
+ */
168
+ ByteCursor CredentialsFileNameOverride;
130
169
};
131
170
132
- /*
171
+ /* *
133
172
* Configuration options for the Ec2 instance metadata service credentials provider
134
173
*/
135
174
struct AWS_CRT_CPP_API CredentialsProviderImdsConfig
136
175
{
137
- CredentialsProviderImdsConfig () : m_bootstrap (nullptr ) {}
176
+ CredentialsProviderImdsConfig () : Bootstrap (nullptr ) {}
138
177
139
- Io::ClientBootstrap *m_bootstrap;
178
+ /* *
179
+ * Connection bootstrap to use to create the http connection required to
180
+ * query credentials from the Ec2 instance metadata service
181
+ */
182
+ Io::ClientBootstrap *Bootstrap;
140
183
};
141
184
142
- /*
185
+ /* *
143
186
* Configuration options for a chain-of-responsibility-based credentials provider.
144
187
* This provider works by traversing the chain and returning the first positive
145
188
* result.
146
189
*/
147
190
struct AWS_CRT_CPP_API CredentialsProviderChainConfig
148
191
{
149
- CredentialsProviderChainConfig () : m_providers () {}
192
+ CredentialsProviderChainConfig () : Providers () {}
150
193
151
- Vector<std::shared_ptr<ICredentialsProvider>> m_providers;
194
+ /* *
195
+ * The sequence of providers that make up the chain.
196
+ */
197
+ Vector<std::shared_ptr<ICredentialsProvider>> Providers;
152
198
};
153
199
154
- /*
200
+ /* *
155
201
* Configuration options for a provider that caches the results of another provider
156
202
*/
157
203
struct AWS_CRT_CPP_API CredentialsProviderCachedConfig
158
204
{
159
- CredentialsProviderCachedConfig () : m_provider( nullptr ), m_refreshTime () {}
205
+ CredentialsProviderCachedConfig () : Provider( ), CachedCredentialTTL () {}
160
206
161
- std::shared_ptr<ICredentialsProvider> m_provider;
162
- std::chrono::milliseconds m_refreshTime;
207
+ /* *
208
+ * The provider to cache credentials from
209
+ */
210
+ std::shared_ptr<ICredentialsProvider> Provider;
211
+
212
+ /* *
213
+ * How long a cached credential set will be used for
214
+ */
215
+ std::chrono::milliseconds CachedCredentialTTL;
163
216
};
164
217
165
- /*
218
+ /* *
166
219
* Configuration options for a provider that implements a cached provider chain
167
220
* based on the AWS SDK defaults:
168
221
*
169
222
* Cache-Of(Environment -> Profile -> IMDS)
170
223
*/
171
224
struct AWS_CRT_CPP_API CredentialsProviderChainDefaultConfig
172
225
{
173
- CredentialsProviderChainDefaultConfig () : m_bootstrap (nullptr ) {}
226
+ CredentialsProviderChainDefaultConfig () : Bootstrap (nullptr ) {}
174
227
175
- Io::ClientBootstrap *m_bootstrap;
228
+ /* *
229
+ * Connection bootstrap to use to create the http connection required to
230
+ * query credentials from the Ec2 instance metadata service
231
+ */
232
+ Io::ClientBootstrap *Bootstrap;
176
233
};
177
234
178
- /*
235
+ /* *
179
236
* Simple credentials provider implementation that wraps one of the internal C-based implementations.
180
237
*
181
238
* Contains a set of static factory methods for building each supported provider, as well as one for the
@@ -195,14 +252,20 @@ namespace Aws
195
252
CredentialsProvider &operator =(const CredentialsProvider &) = delete ;
196
253
CredentialsProvider &operator =(CredentialsProvider &&) = delete ;
197
254
198
- /*
255
+ /* *
199
256
* Asynchronous method to query for AWS credentials based on the internal provider implementation.
200
257
*/
201
258
virtual bool GetCredentials (const OnCredentialsResolved &onCredentialsResolved) const override ;
202
259
260
+ /* *
261
+ * Returns the underlying credentials provider implementation.
262
+ */
203
263
virtual aws_credentials_provider *GetUnderlyingHandle () const noexcept override { return m_provider; }
204
264
205
- virtual operator bool () const noexcept override { return m_provider != nullptr ; }
265
+ /* *
266
+ * Validity check method
267
+ */
268
+ virtual bool IsValid () const noexcept override { return m_provider != nullptr ; }
206
269
207
270
/*
208
271
* Factory methods for all of the basic credentials provider types
@@ -211,50 +274,50 @@ namespace Aws
211
274
*/
212
275
213
276
/* *
214
- * A provider that returns a fixed set of credentials
277
+ * Creates a provider that returns a fixed set of credentials
215
278
*/
216
279
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderStatic (
217
280
const CredentialsProviderStaticConfig &config,
218
281
Allocator *allocator = DefaultAllocator());
219
282
220
- /*
221
- * A provider that returns credentials sourced from environment variables
283
+ /* *
284
+ * Creates a provider that returns credentials sourced from environment variables
222
285
*/
223
286
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderEnvironment (
224
287
Allocator *allocator = DefaultAllocator());
225
288
226
- /*
227
- * A provider that returns credentials sourced from config files
289
+ /* *
290
+ * Creates a provider that returns credentials sourced from config files
228
291
*/
229
292
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderProfile (
230
293
const CredentialsProviderProfileConfig &config,
231
294
Allocator *allocator = DefaultAllocator());
232
295
233
- /*
234
- * A provider that returns credentials sourced from Ec2 instance metadata service
296
+ /* *
297
+ * Creates a provider that returns credentials sourced from Ec2 instance metadata service
235
298
*/
236
299
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderImds (
237
300
const CredentialsProviderImdsConfig &config,
238
301
Allocator *allocator = DefaultAllocator());
239
302
240
- /*
241
- * A provider that sources credentials by querying a series of providers and
303
+ /* *
304
+ * Creates a provider that sources credentials by querying a series of providers and
242
305
* returning the first valid credential set encountered
243
306
*/
244
307
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderChain (
245
308
const CredentialsProviderChainConfig &config,
246
309
Allocator *allocator = DefaultAllocator());
247
310
248
311
/*
249
- * A provider that puts a simple time-based cache in front of its queries
312
+ * Creates a provider that puts a simple time-based cache in front of its queries
250
313
* to a subordinate provider.
251
314
*/
252
315
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderCached (
253
316
const CredentialsProviderCachedConfig &config,
254
317
Allocator *allocator = DefaultAllocator());
255
318
256
- /*
257
- * The SDK-standard default credentials provider which is a cache-fronted chain of:
319
+ /* *
320
+ * Creates the SDK-standard default credentials provider which is a cache-fronted chain of:
258
321
*
259
322
* Environment -> Profile -> IMDS
260
323
*
0 commit comments