Skip to content

Adding CRTProfileCredentialsProvider for CRT-based profile credential#3713

Open
pulimsr wants to merge 7 commits intomainfrom
crt-profile-credentials-provider
Open

Adding CRTProfileCredentialsProvider for CRT-based profile credential#3713
pulimsr wants to merge 7 commits intomainfrom
crt-profile-credentials-provider

Conversation

@pulimsr
Copy link
Contributor

@pulimsr pulimsr commented Feb 3, 2026

Adding CRTProfileCredentialsProvider for CRT-based profile credential

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Adding CRTProfileCredentialsProvider for CRT-based profile credential
void Reload() override;

private:
class Impl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when trying to do pimpl with the profile credentials provider i see it more so going like this.

In the real profile credentials provider

class AWS_CORE_API ProfileConfigFileAWSCredentialsProvider : public AWSCredentialsProvider
{
public:
  ProfileConfigFileAWSCredentialsProvider(long refreshRateMs = REFRESH_THRESHOLD);
  ProfileConfigFileAWSCredentialsProvider(const char* profile, long refreshRateMs = REFRESH_THRESHOLD);
  AWSCredentials GetAWSCredentials() override;
  static Aws::String GetCredentialsProfileFilename();
  static Aws::String GetProfileDirectory();

protected:
  void Reload() override;
private:
  void RefreshIfExpired();
  Aws::String m_profileToUse;
  Aws::Config::AWSConfigFileProfileConfigLoader m_credentialsFileLoader;
  long m_loadFrequencyMs;
};

becomes

class ProfileCredentialsProviderImpl;

class AWS_CORE_API ProfileConfigFileAWSCredentialsProvider : public AWSCredentialsProvider
{
public:
  ProfileConfigFileAWSCredentialsProvider(long refreshRateMs = REFRESH_THRESHOLD);
  ProfileConfigFileAWSCredentialsProvider(const char* profile, long refreshRateMs = REFRESH_THRESHOLD);
  AWSCredentials GetAWSCredentials() override;
  static Aws::String GetCredentialsProfileFilename();
  static Aws::String GetProfileDirectory();

protected:
  void Reload() override;
  Aws::UniquePtr<ProfileCredentialsProviderImpl> m_impl;
};

then in the cpp file for for ProfileConfigFileAWSCredentialsProvider we construct a point to ProfileCredentialsProviderImpl.

That is step one to move the existing credentials provider to PIMPL.

Then step two is your change, ProfileCredentialsProviderImpl is changed to the implementation of your existing CRTProfileCredentialsProvider.

So:
Step 1: change ProfileConfigFileAWSCredentialsProvider to use PIMPL to current existing implementation called ProfileCredentialsProviderImpl.
Step 2: change ProfileCredentialsProviderImpl to us the implementation from this PR.

* CRT-based credentials provider that sources credentials from config files with full SEP compliance.
* Supports assume role, credential_source, role chaining, and all SEP scenarios.
*/
class AWS_CORE_API CRTProfileCredentialsProvider : public AWSCredentialsProvider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not name this CRTProfileCredentialsProvider because its just going to be the new ProfileCredentialsProvider. lets just name it ProfileCredentialsProvider. also please add a AWS_DEPRECATED to the old class so that people using it directly will get a warning to update to the new one.

protected:
void Reload() override;
class CRTProfileCredentialsProviderImp;
std::shared_ptr<CRTProfileCredentialsProviderImp> m_impl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chefs kiss

std::shared_ptr<CRTProfileCredentialsProviderImp> m_impl;

private:
void RefreshIfExpired();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we still need this private method? cant we jsut move it to the impl?

long m_loadFrequencyMs;

CRTProfileCredentialsProviderImp(long refreshRateMs) :
m_profileToUse(Aws::Auth::GetConfigProfileName()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should still keep data members as private. ideally the impl should just be the interface of a aws credentials provider


void CRTProfileCredentialsProvider::Reload()
{
m_impl->m_credentialsFileLoader.Load();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should just call m_impl->Reload() and all the logic should be moved to the impl


void CRTProfileCredentialsProvider::RefreshIfExpired()
{
ReaderLockGuard guard(m_reloadLock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should just call m_impl->RefreshIfExpired() and all the logic shold be move to the impl class


AWSCredentials CRTProfileCredentialsProvider::GetAWSCredentials()
{
RefreshIfExpired();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should just call m_impl->GetAWSCredentials() and all of this logic should be moved there

m_loadFrequencyMs(refreshRateMs){}

CRTProfileCredentialsProviderImp(const char* profile, long refreshRateMs) :
m_profileToUse(profile),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit formatting -- does clang format like this? if so diregard

#include <aws/core/platform/FileSystem.h>
#include <aws/core/utils/logging/LogMacros.h>
#include <aws/core/client/UserAgent.h>
#include <cstdlib>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need cstdlib/string.h/climits here? they seem sort of suspect imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants