Skip to content

[aws-cpp-sdk-core]: re-implement refreshing for ProfileCredentialsProvider - #4009

Open
grrtrr wants to merge 1 commit into
aws:mainfrom
grrtrr:issue_4004
Open

grrtrr wants to merge 1 commit into
aws:mainfrom
grrtrr:issue_4004

Conversation

@grrtrr

@grrtrr grrtrr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

This restores the RefreshIfExpired logic of the ProfileCredentialsProvider, which was removed in #3721.

Resolves #4008.

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.

…vider

This restores the `RefreshIfExpired` logic of the `ProfileCredentialsProvider`, which
was removed in aws#3721.

Resolves aws#4008.
@@ -37,15 +37,17 @@ class AWS_CORE_API CrtCredentialsProvider : public AWSCredentialsProvider {
*/
AWSCredentials GetAWSCredentials() override;

protected:
void Reload() override;
virtual void RefreshIfExpired();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made RefreshIfExpired() virtual, since CrtCredentialsProvider::GetAWSCredentials() calls this, and only this method needs to be changed.

Comment on lines -50 to -51
protected:
void Reload() override;

@grrtrr grrtrr Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This method was empty (see below), so removed.

using namespace Aws::Crt::Auth;

namespace {
const char PROFILE_AWS_CREDENTIALS_FILE[] = "AWS_SHARED_CREDENTIALS_FILE";
const char PROFILE_DEFAULT_CREDENTIALS_FILE[] = "credentials";
const char PROFILE_PROFILE_DIRECTORY[] = ".aws";
const long DEFAULT_REFRESH_RATE_MS = 300000;
const long PROFILE_FUTURES_TIMEOUT_MS = 60'000;

@grrtrr grrtrr Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This constant is only used for the futures timeout.

For parsing profile files, even with network-bound calls, 60 seconds is plenty.

}

Reload();
AWSCredentialsProvider::Reload();

@grrtrr grrtrr Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Call the base class Reload() method to reset m_lastLoadedMs.

void AWSCredentialsProvider::Reload()
{
m_lastLoadedMs = DateTime::Now().Millis();
}
bool AWSCredentialsProvider::IsTimeToRefresh(long reloadFrequency)
{
if (DateTime::Now().Millis() - m_lastLoadedMs > reloadFrequency)
{
return true;
}
return false;
}

@grrtrr grrtrr changed the title [aws-cpp-sdk-core]: re-implement refreshing for ProfileCredentialsPro… [aws-cpp-sdk-core]: re-implement refreshing for ProfileCredentialsProvider Nov 23, 2026

This branch has not been deployed

No deployments
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.

[aws-cpp-sdk-core]: ProfileCredentialsProvider no longer refreshes profile data

1 participant