Skip to content

Fix refresh request consumer invocation for web identity credentials - #7273

Draft
YuqiGuo105 wants to merge 1 commit into
aws:masterfrom
YuqiGuo105:fix/issue-5709-refresh-request-consumer
Draft

Fix refresh request consumer invocation for web identity credentials#7273
YuqiGuo105 wants to merge 1 commit into
aws:masterfrom
YuqiGuo105:fix/issue-5709-refresh-request-consumer

Conversation

@YuqiGuo105

@YuqiGuo105 YuqiGuo105 commented Aug 13, 2026

Copy link
Copy Markdown

Motivation and Context

The Consumer overload of StsAssumeRoleWithWebIdentityCredentialsProvider.Builder.refreshRequest eagerly built an AssumeRoleWithWebIdentityRequest and delegated to the fixed-request overload. As a result, later credential refreshes reused the same request and web identity token instead of invoking the consumer again.

This can cause credential refresh to fail after a dynamically supplied web identity token expires.

Fixes #5709

Modifications

  • Defer request construction by wrapping the builder mutation in the existing request Supplier.
  • Invoke the Consumer whenever credentials are refreshed and a new request is obtained.
  • Clarify the per-refresh invocation behavior in the method Javadoc.
  • Add a regression test that forces two credential refreshes and verifies that STS receives token-1 followed by token-2.

The change is intentionally scoped to the Consumer overload on StsAssumeRoleWithWebIdentityCredentialsProvider. The fixed request and explicit Supplier overloads are unchanged.

Testing

  • ./mvnw install -pl :sts -P quick -am
  • ./mvnw -pl :sts -Dtest=StsAssumeRoleWithWebIdentityCredentialsProviderTest -Dspotbugs.skip=true test
  • Verified that the new regression test fails before the implementation change with token-1 used twice.
  • Verified that all 7 tests in StsAssumeRoleWithWebIdentityCredentialsProviderTest pass after the change.
  • Checkstyle completed with 0 violations.
  • git diff --check completed successfully.

Screenshots

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

This pull request was generated with assistance from AI tools and reviewed by Yuqi Guo.

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.

StsAssumeRoleWithWebIdentityCredentialsProvider does not call refreshRequest

1 participant