Skip to content

STS profile credentail doesn't get updated 5 minutes before expiry #3305

Closed
@phoebusm

Description

@phoebusm

Describe the bug

if (!IsTimeToRefresh(static_cast<long>(m_reloadFrequency.count())) || !m_credentials.IsExpiredOrEmpty())

The condition of credential refresh doesn't get refreshed 5 minutes before expiry, as specified in the constructor:
m_reloadFrequency(std::chrono::minutes(std::max(int64_t(5), static_cast<int64_t>(duration.count()))) - std::chrono::minutes(5)),

as the refresh can only be made if m_credentials.IsExpiredOrEmpty() == true.

As a result, the token could pass the expiry check here but rejected by the endpoint milisecond later.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Reference: class STSCredentialsProvider :

if (!m_credentials.IsEmpty() && !ExpiresSoon())

Have a grace period. Refresh token minutes before expiry

Current Behavior

Refresh only when the credential is found to be expired during checking

Reproduction Steps

  1. Enable logging
  2. Create a connection to aws endpoint with STSProfileCredentialsProvider.cpp
  3. Call some s3 api, e.g. ListObjectV2, per second
  4. By reading the log, it can be determined when does the refresh happen

Possible Solution

|| to && in the conditions

Additional Information/Context

No response

AWS CPP SDK version used

1.11.474

Compiler and Version used

gcc version 11.4.0

Operating System and version

Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions