LoadOptions for wrapWithCredentialsCache
- Dominant language
- Go
- Stars
- 3.6k
- Forks
- 816
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 18
Description
### Describe the feature
When resolving credentials, it would be nice to be able to define `wrapWithCredentialsCache` used [here](https://github.com/aws/aws-sdk-go-v2/blob/28e7ef89093896b16b92b2fa3077e826b7a3c4a8/config/resolve_credentials.go#L461).
Consumer of AWS library could define their own credential cache mechanism (eg asynchronous) while beneficiate from `resolveCredentialChain` to get the right credential provider.
### Use Case
Credential Cache does not support asynchronous retrieval of credentials.
To be able to achieve this, it requires changes inside credential cache ([PR](https://github.com/aws/aws-sdk-go-v2/pull/1982) aborted) or redefine provider after `config.LoadDefaultConfig` has been called (if consume wants to beneficiates from default configuration).
### Proposed Solution
Adding LoadOptions:
```
// WrapWithCredentialsCache will wrap provider with custom credentialCache with the provided options
// default: aws.CredentialsCache if the provider is not already a aws.CredentialsCache
WrapWithCredentialsCache func(provider aws.CredentialsProvider, optFns ...func(options *aws.CredentialsCacheOptions)) aws.CredentialsProvider
```
```
func WithWrapWithCredentialsCache(v func(provider aws.CredentialsProvider, optFns ...func(options *aws.CredentialsCacheOptions)) aws.CredentialsProvider) aws.CredentialsProvider) LoadOptionsFunc {
return func(o *LoadOptions) error {
o.WrapWithCredentialsCache = v
return nil
}
}
```
### Other Information
_No response_
### Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2@v1.17.3
github.com/aws/aws-sdk-go-v2/config@v1.18.10
github.com/aws/aws-sdk-go-v2/credentials@v1.13.10
### Go version used
1.19
Contributor guide
Research direction
Start in config/resolve_credentials.go at wrapWithCredentialsCache and trace how LoadOptions reaches resolveCredentialChain. Check the existing credential-cache behavior and determine how a custom wrapper option should preserve the default path. Done means callers can supply their own wrapper, including its cache options, without losing the standard credential resolution behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- authentication
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100