AWS SDK for C++  1.8.149
AWS SDK for C++
AWSCredentialsProvider.h
Go to the documentation of this file.
1 
7 #pragma once
8 
19 #include <memory>
20 
21 namespace Aws
22 {
23  namespace Auth
24  {
25  constexpr int REFRESH_THRESHOLD = 1000 * 60 * 5;
26 
31 
39  AWS_CORE_API Aws::String GetConfigProfileName(); //defaults to "default"
40 
41  /*
42  * Fetches credentials by executing the process in the parameter
43  */
45 
51  {
52  public:
57  AWSCredentialsProvider() : m_lastLoadedMs(0)
58  {
59  }
60 
61  virtual ~AWSCredentialsProvider() = default;
62 
67 
68  protected:
73  virtual bool IsTimeToRefresh(long reloadFrequency);
74  virtual void Reload();
76  private:
77  long long m_lastLoadedMs;
78  };
79 
85  {
86  public:
90  inline AWSCredentials GetAWSCredentials() override { return AWSCredentials(); }
91  };
92 
99  {
100  public:
104  inline SimpleAWSCredentialsProvider(const Aws::String& awsAccessKeyId, const Aws::String& awsSecretAccessKey, const Aws::String& sessionToken = "")
105  : m_credentials(awsAccessKeyId, awsSecretAccessKey, sessionToken)
106  { }
107 
111  inline SimpleAWSCredentialsProvider(const AWSCredentials& credentials)
112  : m_credentials(credentials)
113  { }
114 
119  {
120  return m_credentials;
121  }
122 
123  private:
124  AWSCredentials m_credentials;
125  };
126 
132  {
133  public:
139  };
140 
149  {
150  public:
151 
156 
161  ProfileConfigFileAWSCredentialsProvider(const char* profile, long refreshRateMs = REFRESH_THRESHOLD);
162 
167 
172 
177 
178  protected:
179  void Reload() override;
180  private:
181 
185  void RefreshIfExpired();
186 
187  Aws::String m_profileToUse;
188  Aws::Config::AWSConfigFileProfileConfigLoader m_credentialsFileLoader;
189  long m_loadFrequencyMs;
190  };
191 
197  {
198  public:
204 
209  InstanceProfileCredentialsProvider(const std::shared_ptr<Aws::Config::EC2InstanceProfileConfigLoader>&, long refreshRateMs = REFRESH_THRESHOLD);
210 
215 
216  protected:
217  void Reload() override;
218 
219  private:
220  void RefreshIfExpired();
221 
222  std::shared_ptr<Aws::Config::AWSProfileConfigLoader> m_ec2MetadataConfigLoader;
223  long m_loadFrequencyMs;
224  };
225 
231  {
232  public:
239  TaskRoleCredentialsProvider(const char* resourcePath, long refreshRateMs = REFRESH_THRESHOLD);
240 
248  TaskRoleCredentialsProvider(const char* endpoint, const char* token, long refreshRateMs = REFRESH_THRESHOLD);
249 
255  TaskRoleCredentialsProvider(const std::shared_ptr<Aws::Internal::ECSCredentialsClient>& client,
256  long refreshRateMs = REFRESH_THRESHOLD);
261 
262  protected:
263  void Reload() override;
264  private:
265  bool ExpiresSoon() const;
266  void RefreshIfExpired();
267 
268  private:
269  std::shared_ptr<Aws::Internal::ECSCredentialsClient> m_ecsCredentialsClient;
270  long m_loadFrequencyMs;
271  Aws::Auth::AWSCredentials m_credentials;
272  };
273 
288  {
289  public:
294 
300 
305 
306  protected:
307  void Reload() override;
308  private:
309  void RefreshIfExpired();
310 
311  private:
312  Aws::String m_profileToUse;
313  Aws::Auth::AWSCredentials m_credentials;
314  };
315  } // namespace Auth
316 } // namespace Aws
Aws::Auth::ProcessCredentialsProvider
Definition: AWSCredentialsProvider.h:288
Aws::Auth::InstanceProfileCredentialsProvider::InstanceProfileCredentialsProvider
InstanceProfileCredentialsProvider(long refreshRateMs=REFRESH_THRESHOLD)
Aws::Auth::TaskRoleCredentialsProvider::Reload
void Reload() override
Aws::Auth::TaskRoleCredentialsProvider::TaskRoleCredentialsProvider
TaskRoleCredentialsProvider(const char *resourcePath, long refreshRateMs=REFRESH_THRESHOLD)
Aws::Auth::REFRESH_THRESHOLD
constexpr int REFRESH_THRESHOLD
Definition: AWSCredentialsProvider.h:25
AWSProfileConfigLoader.h
Aws::Auth::TaskRoleCredentialsProvider
Definition: AWSCredentialsProvider.h:231
AWS_CORE_API
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25
Aws::Auth::ProfileConfigFileAWSCredentialsProvider::GetAWSCredentials
AWSCredentials GetAWSCredentials() override
Aws::Auth::SimpleAWSCredentialsProvider::SimpleAWSCredentialsProvider
SimpleAWSCredentialsProvider(const AWSCredentials &credentials)
Definition: AWSCredentialsProvider.h:111
Aws::Auth::SimpleAWSCredentialsProvider::SimpleAWSCredentialsProvider
SimpleAWSCredentialsProvider(const Aws::String &awsAccessKeyId, const Aws::String &awsSecretAccessKey, const Aws::String &sessionToken="")
Definition: AWSCredentialsProvider.h:104
Aws::Auth::TaskRoleCredentialsProvider::GetAWSCredentials
AWSCredentials GetAWSCredentials() override
DateTime.h
Aws::Auth::AWSCredentialsProvider::Reload
virtual void Reload()
Aws::Auth::ProcessCredentialsProvider::ProcessCredentialsProvider
ProcessCredentialsProvider()
AWSCredentials.h
Aws::Auth::ProcessCredentialsProvider::ProcessCredentialsProvider
ProcessCredentialsProvider(const Aws::String &profile)
Aws::Auth::SimpleAWSCredentialsProvider
Definition: AWSCredentialsProvider.h:99
Aws::Auth::GetCredentialsFromProcess
AWS_CORE_API AWSCredentials GetCredentialsFromProcess(const Aws::String &process)
Aws::Auth::ProfileConfigFileAWSCredentialsProvider::GetProfileDirectory
static Aws::String GetProfileDirectory()
Aws::Auth::AWSCredentialsProvider
Definition: AWSCredentialsProvider.h:51
Aws::Auth::AWSCredentialsProvider::m_reloadLock
Aws::Utils::Threading::ReaderWriterLock m_reloadLock
Definition: AWSCredentialsProvider.h:75
Aws::Auth::EnvironmentAWSCredentialsProvider::GetAWSCredentials
AWSCredentials GetAWSCredentials() override
Aws::Auth::InstanceProfileCredentialsProvider::Reload
void Reload() override
Aws::Config::AWSConfigFileProfileConfigLoader
Definition: AWSProfileConfigLoader.h:111
ReaderWriterLock.h
Aws::Auth::AWSCredentialsProvider::~AWSCredentialsProvider
virtual ~AWSCredentialsProvider()=default
Aws::Auth::AnonymousAWSCredentialsProvider::GetAWSCredentials
AWSCredentials GetAWSCredentials() override
Definition: AWSCredentialsProvider.h:90
Aws::Auth::ProfileConfigFileAWSCredentialsProvider::Reload
void Reload() override
Aws::Auth::AWSCredentials
Definition: AWSCredentials.h:19
Aws::Auth::AWSCredentialsProvider::AWSCredentialsProvider
AWSCredentialsProvider()
Definition: AWSCredentialsProvider.h:57
Aws::Auth::ProfileConfigFileAWSCredentialsProvider::ProfileConfigFileAWSCredentialsProvider
ProfileConfigFileAWSCredentialsProvider(const char *profile, long refreshRateMs=REFRESH_THRESHOLD)
Aws::Auth::AWSCredentialsProvider::GetAWSCredentials
virtual AWSCredentials GetAWSCredentials()=0
Aws::Auth::AWSCredentialsProvider::IsTimeToRefresh
virtual bool IsTimeToRefresh(long reloadFrequency)
Aws::Auth::GetConfigProfileName
AWS_CORE_API Aws::String GetConfigProfileName()
AWSString.h
Aws::Auth::AnonymousAWSCredentialsProvider
Definition: AWSCredentialsProvider.h:85
Aws::Auth::TaskRoleCredentialsProvider::TaskRoleCredentialsProvider
TaskRoleCredentialsProvider(const char *endpoint, const char *token, long refreshRateMs=REFRESH_THRESHOLD)
Aws::Utils::Threading::ReaderWriterLock
Definition: ReaderWriterLock.h:26
Aws::Auth::ProcessCredentialsProvider::Reload
void Reload() override
Aws::Auth::InstanceProfileCredentialsProvider::GetAWSCredentials
AWSCredentials GetAWSCredentials() override
Core_EXPORTS.h
AWSHttpResourceClient.h
Aws
Definition: AccessManagementClient.h:15
Aws::Auth::SimpleAWSCredentialsProvider::GetAWSCredentials
AWSCredentials GetAWSCredentials() override
Definition: AWSCredentialsProvider.h:118
Aws::Auth::ProfileConfigFileAWSCredentialsProvider::GetCredentialsProfileFilename
static Aws::String GetCredentialsProfileFilename()
Aws::String
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
UnreferencedParam.h
Aws::Auth::GetConfigProfileFilename
AWS_CORE_API Aws::String GetConfigProfileFilename()
Aws::Auth::InstanceProfileCredentialsProvider::InstanceProfileCredentialsProvider
InstanceProfileCredentialsProvider(const std::shared_ptr< Aws::Config::EC2InstanceProfileConfigLoader > &, long refreshRateMs=REFRESH_THRESHOLD)
RetryStrategy.h
Aws::Auth::EnvironmentAWSCredentialsProvider
Definition: AWSCredentialsProvider.h:132
AWSMap.h
Aws::Auth::TaskRoleCredentialsProvider::TaskRoleCredentialsProvider
TaskRoleCredentialsProvider(const std::shared_ptr< Aws::Internal::ECSCredentialsClient > &client, long refreshRateMs=REFRESH_THRESHOLD)
Aws::Auth::InstanceProfileCredentialsProvider
Definition: AWSCredentialsProvider.h:197
Aws::Auth::ProfileConfigFileAWSCredentialsProvider::ProfileConfigFileAWSCredentialsProvider
ProfileConfigFileAWSCredentialsProvider(long refreshRateMs=REFRESH_THRESHOLD)
Aws::Auth::ProfileConfigFileAWSCredentialsProvider
Definition: AWSCredentialsProvider.h:149
Aws::Auth::ProcessCredentialsProvider::GetAWSCredentials
AWSCredentials GetAWSCredentials() override