Skip to content

Commit 7e72f1a

Browse files
authored
Ga prep (aws#57)
* Doxygen + misc updates * Rework trivial config types to remove accessors
1 parent 1bafd4e commit 7e72f1a

18 files changed

+399
-365
lines changed

include/aws/crt/auth/Credentials.h

Lines changed: 111 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Aws
3434

3535
namespace Auth
3636
{
37-
/*
37+
/**
3838
* A class to hold the basic components necessary for various AWS authentication protocols.
3939
*/
4040
class AWS_CRT_CPP_API Credentials
@@ -54,128 +54,185 @@ namespace Aws
5454
Credentials &operator=(const Credentials &) = delete;
5555
Credentials &operator=(Credentials &&) = delete;
5656

57+
/**
58+
* Gets the value of the access key component of aws credentials
59+
*/
5760
ByteCursor GetAccessKeyId() const noexcept;
5861

62+
/**
63+
* Gets the value of the secret access key component of aws credentials
64+
*/
5965
ByteCursor GetSecretAccessKey() const noexcept;
6066

67+
/**
68+
* Gets the value of the session token of aws credentials
69+
*/
6170
ByteCursor GetSessionToken() const noexcept;
6271

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;
6476

77+
/**
78+
* Returns the underlying credentials implementation.
79+
*/
6580
aws_credentials *GetUnderlyingHandle() const noexcept { return m_credentials; }
6681

6782
private:
6883
aws_credentials *m_credentials;
6984
};
7085

71-
/*
86+
/**
7287
* Callback invoked by credentials providers when resolution succeeds (credentials will be non-null)
7388
* or fails (credentials will be null)
7489
*/
7590
using OnCredentialsResolved = std::function<void(std::shared_ptr<Credentials>)>;
7691

77-
/*
92+
/**
7893
* 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.
8095
*/
8196
class AWS_CRT_CPP_API ICredentialsProvider : public std::enable_shared_from_this<ICredentialsProvider>
8297
{
8398
public:
8499
virtual ~ICredentialsProvider() = default;
85100

86-
/*
101+
/**
87102
* Asynchronous method to query for AWS credentials based on the internal provider implementation.
88103
*/
89104
virtual bool GetCredentials(const OnCredentialsResolved &onCredentialsResolved) const = 0;
90105

91-
/*
106+
/**
92107
* Returns the underlying credentials provider implementation. Support for credentials providers
93108
* not based on a C implementation is theoretically possible, but requires some re-implementation to
94109
* support provider chains and caching (whose implementations rely on links to C implementation
95110
* providers)
96111
*/
97112
virtual aws_credentials_provider *GetUnderlyingHandle() const noexcept = 0;
98113

99-
/*
100-
* Validity check
114+
/**
115+
* Validity check method
101116
*/
102-
virtual operator bool() const noexcept = 0;
117+
virtual bool IsValid() const noexcept = 0;
103118
};
104119

105-
/*
120+
/**
106121
* Configuration options for the static credentials provider
107122
*/
108123
struct AWS_CRT_CPP_API CredentialsProviderStaticConfig
109124
{
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;
111131

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;
115141
};
116142

117-
/*
143+
/**
118144
* Configuration options for the profile credentials provider
119145
*/
120146
struct AWS_CRT_CPP_API CredentialsProviderProfileConfig
121147
{
122148
CredentialsProviderProfileConfig()
123-
: m_profileNameOverride(), m_configFileNameOverride(), m_credentialsFileNameOverride()
149+
: ProfileNameOverride{}, ConfigFileNameOverride{}, CredentialsFileNameOverride{}
124150
{
125151
}
126152

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;
130169
};
131170

132-
/*
171+
/**
133172
* Configuration options for the Ec2 instance metadata service credentials provider
134173
*/
135174
struct AWS_CRT_CPP_API CredentialsProviderImdsConfig
136175
{
137-
CredentialsProviderImdsConfig() : m_bootstrap(nullptr) {}
176+
CredentialsProviderImdsConfig() : Bootstrap(nullptr) {}
138177

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;
140183
};
141184

142-
/*
185+
/**
143186
* Configuration options for a chain-of-responsibility-based credentials provider.
144187
* This provider works by traversing the chain and returning the first positive
145188
* result.
146189
*/
147190
struct AWS_CRT_CPP_API CredentialsProviderChainConfig
148191
{
149-
CredentialsProviderChainConfig() : m_providers() {}
192+
CredentialsProviderChainConfig() : Providers() {}
150193

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;
152198
};
153199

154-
/*
200+
/**
155201
* Configuration options for a provider that caches the results of another provider
156202
*/
157203
struct AWS_CRT_CPP_API CredentialsProviderCachedConfig
158204
{
159-
CredentialsProviderCachedConfig() : m_provider(nullptr), m_refreshTime() {}
205+
CredentialsProviderCachedConfig() : Provider(), CachedCredentialTTL() {}
160206

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;
163216
};
164217

165-
/*
218+
/**
166219
* Configuration options for a provider that implements a cached provider chain
167220
* based on the AWS SDK defaults:
168221
*
169222
* Cache-Of(Environment -> Profile -> IMDS)
170223
*/
171224
struct AWS_CRT_CPP_API CredentialsProviderChainDefaultConfig
172225
{
173-
CredentialsProviderChainDefaultConfig() : m_bootstrap(nullptr) {}
226+
CredentialsProviderChainDefaultConfig() : Bootstrap(nullptr) {}
174227

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;
176233
};
177234

178-
/*
235+
/**
179236
* Simple credentials provider implementation that wraps one of the internal C-based implementations.
180237
*
181238
* Contains a set of static factory methods for building each supported provider, as well as one for the
@@ -195,14 +252,20 @@ namespace Aws
195252
CredentialsProvider &operator=(const CredentialsProvider &) = delete;
196253
CredentialsProvider &operator=(CredentialsProvider &&) = delete;
197254

198-
/*
255+
/**
199256
* Asynchronous method to query for AWS credentials based on the internal provider implementation.
200257
*/
201258
virtual bool GetCredentials(const OnCredentialsResolved &onCredentialsResolved) const override;
202259

260+
/**
261+
* Returns the underlying credentials provider implementation.
262+
*/
203263
virtual aws_credentials_provider *GetUnderlyingHandle() const noexcept override { return m_provider; }
204264

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; }
206269

207270
/*
208271
* Factory methods for all of the basic credentials provider types
@@ -211,50 +274,50 @@ namespace Aws
211274
*/
212275

213276
/**
214-
* A provider that returns a fixed set of credentials
277+
* Creates a provider that returns a fixed set of credentials
215278
*/
216279
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderStatic(
217280
const CredentialsProviderStaticConfig &config,
218281
Allocator *allocator = DefaultAllocator());
219282

220-
/*
221-
* A provider that returns credentials sourced from environment variables
283+
/**
284+
* Creates a provider that returns credentials sourced from environment variables
222285
*/
223286
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderEnvironment(
224287
Allocator *allocator = DefaultAllocator());
225288

226-
/*
227-
* A provider that returns credentials sourced from config files
289+
/**
290+
* Creates a provider that returns credentials sourced from config files
228291
*/
229292
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderProfile(
230293
const CredentialsProviderProfileConfig &config,
231294
Allocator *allocator = DefaultAllocator());
232295

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
235298
*/
236299
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderImds(
237300
const CredentialsProviderImdsConfig &config,
238301
Allocator *allocator = DefaultAllocator());
239302

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
242305
* returning the first valid credential set encountered
243306
*/
244307
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderChain(
245308
const CredentialsProviderChainConfig &config,
246309
Allocator *allocator = DefaultAllocator());
247310

248311
/*
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
250313
* to a subordinate provider.
251314
*/
252315
static std::shared_ptr<ICredentialsProvider> CreateCredentialsProviderCached(
253316
const CredentialsProviderCachedConfig &config,
254317
Allocator *allocator = DefaultAllocator());
255318

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:
258321
*
259322
* Environment -> Profile -> IMDS
260323
*

include/aws/crt/auth/Signing.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Aws
3737
Aws = AWS_SIGNING_CONFIG_AWS
3838
};
3939

40-
/*
40+
/**
4141
* Base class for all different signing configurations. Type functions as a
4242
* primitive RTTI for downcasting.
4343
*/
@@ -52,10 +52,13 @@ namespace Aws
5252

5353
virtual ~ISigningConfig() = default;
5454

55+
/**
56+
* RTTI query for the SigningConfig hierarchy
57+
*/
5558
virtual SigningConfigType GetType(void) const = 0;
5659
};
5760

58-
/*
61+
/**
5962
* Abstract base for all http request signers. Synchronous interface. Intended to
6063
* be a tight wrapper around aws-c-* signer implementations.
6164
*/
@@ -70,19 +73,26 @@ namespace Aws
7073

7174
virtual ~IHttpRequestSigner() = default;
7275

76+
/**
77+
* Synchronous method to use a signing process to transform an http request.
78+
* Thread-safe.
79+
*/
7380
virtual bool SignRequest(Aws::Crt::Http::HttpRequest &request, const ISigningConfig *config) = 0;
7481

75-
virtual operator bool() const = 0;
82+
/**
83+
* Whether or not the signer is in a valid state
84+
*/
85+
virtual bool IsValid() const = 0;
7686
};
7787

78-
/*
88+
/**
7989
* Signing pipeline callback. The second parameter is an aws error code, The signing was successful
8090
* iff the error code is AWS_ERROR_SUCCESS.
8191
*/
8292
using OnHttpRequestSigningComplete =
8393
std::function<void(const std::shared_ptr<Aws::Crt::Http::HttpRequest> &, int)>;
8494

85-
/*
95+
/**
8696
* Abstract base for a complete signing process. While the primary difference between this
8797
* and IHttpRequestSigner is one of async vs. sync, the intent of this interface is to encapsulate an
8898
* entire signing process that may involve multiple asynchronous steps (Sigv4 with credentials fetch, OAuth,
@@ -99,12 +109,19 @@ namespace Aws
99109

100110
virtual ~IHttpRequestSigningPipeline() = default;
101111

112+
/**
113+
* Asynchronous method to use a signing process/pipeline to transform an http request.
114+
* Thread-safe.
115+
*/
102116
virtual void SignRequest(
103117
const std::shared_ptr<Aws::Crt::Http::HttpRequest> &request,
104118
const std::shared_ptr<ISigningConfig> &config,
105119
const OnHttpRequestSigningComplete &completionCallback) = 0;
106120

107-
virtual operator bool() const = 0;
121+
/**
122+
* Whether or not the signing pipeline is in a valid state
123+
*/
124+
virtual bool IsValid() const = 0;
108125
};
109126

110127
} // namespace Auth

0 commit comments

Comments
 (0)