Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(middleware-signing): memoize temporary credentials #2109

Merged
merged 1 commit into from
Mar 11, 2021

Conversation

AllanZhengYP
Copy link
Contributor

Issue

Resolves #2107

Description

It turns out not difficult to fix. When resolving the credentails in the resolveAwsAuthConfig(), if the user supplies a customer credential provider, the client will memoize the resolved value. If the resolved value is expired, the credential will be reloaded. If the credential provider only returns a static credential(never expires), the credential will keep memoized.


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

if (typeof credentials === "function") {
return memoize(
credentials,
(credentials) => credentials.expiration !== undefined && credentials.expiration.getTime() - Date.now() < 300000,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we pull this magic number into a named const?

Copy link
Contributor

@alexforsyth alexforsyth left a comment

Choose a reason for hiding this comment

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

Nits, lgtm

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@49e2d61). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2109   +/-   ##
=======================================
  Coverage        ?   78.68%           
=======================================
  Files           ?      380           
  Lines           ?    16080           
  Branches        ?     3444           
=======================================
  Hits            ?    12653           
  Misses          ?     3427           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49e2d61...177c709. Read the comment docs.

@AllanZhengYP AllanZhengYP merged commit cf238b9 into aws:main Mar 11, 2021
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 177c709
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic Credentials are Refreshed Too Often
4 participants