-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support credential caching by sdk users. #2375
Conversation
Add an Expirer interface that Providers can implement, and add a suitable implementation to Expiry class used by most Providers. Add a method on Credentials to get the expiration time of the underlying Provider, if Expirer is supported, without exposing Provider to callers.
@jasdel could you take a look at this PR? Needless to say, it would be great to get it accepted and released ASAP so that I can submit a pull to the aws-iam-authenticator project that depends on this. Would rather not hand vendor this directly in their project. |
It would be great to get this accepted and released soon. It's blocking my ability to create a pull request for aws-iam-authenticator fixing the lack of SSO credential caching there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting together this PR. I think we could take this feature, with a few updates to protecting against race retrieving the expiration time, and handling credentials that have already "expired".
Expire() directive by returing an expired time for ExpiresAt()
Let me know if you want me to squash these changes together. |
Any chance this pull could be accepted soon? |
Thanks for the updates, I'll review these. The |
But.... no one calls Credentials.Expire() or sets forceRefresh to true after Credentials.Get() is called. It seems unused in any non testing/example part of the SDK. Unimplemented feature? |
Or is this API for applications written on top of the SDK to force credential expiration? Seems odd to push that up out of the SDK, tho. |
The SDK's built in request handler AfterRetryHandler will call Expire if the service's API response has an error that signifies the credentials are no longer valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making these updates the changes look good. We won't be able to merge the change in today, but will be able to after the new year.
Thanks for taking the time to create this PR, and updates.
apologies... I somehow missed that one when searching. So, if I'm caching credentials at a higher level in the calling program, and the credential I'm using is expired, the AfterRetryHandler will call Expire on the Credential, and then... it looks like... automatically retry? I don't think I will need to do anything special so long as I support the forceRetry flag on ExpiresAt() |
Will your application be caching the Using the |
It will be caching credentials.Value to disk, and only calling Credentials.Get() if the on disk cache of the credentials.Value has an expiration time that is in the past. This is per your suggestions in issue #1329. |
Also, FWIW, it seems to work fine. Already have implemented it for aws-iam-authenticator. Just waiting for this pull request to go in before submitting a pull to that project. |
HNY! What's the schedule look like for pulling this and publishing a new release including it? |
Thanks for creating this PR. I've merged it into master, and it will be included in the next tagged release. I expect a tagged release to be created this week. |
Add an Expirer interface that Providers can implement, and add a suitable
implementation to Expiry class used by most Providers. Add a method on
Credentials to get the expiration time of the underlying Provider, if
Expirer is supported, without exposing Provider to callers.
If there is an existing bug or feature this PR is answers please reference it here.
Provides partial solution to issue #1329 discussion.