-
Couldn't load subscription status.
- Fork 13
feat: adding expiration time for secret cache in secret manager plugin #906
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
Conversation
bf31ec5 to
928d4e0
Compare
docs/using-the-python-driver/using-plugins/UsingTheAwsSecretsManagerPlugin.md
Outdated
Show resolved
Hide resolved
928d4e0 to
ca99cc4
Compare
9961ade to
59dfd8b
Compare
| self._secret = self._fetch_latest_credentials() | ||
| if self._secret: | ||
| AwsSecretsManagerPlugin._secrets_cache[self._secret_key] = self._secret | ||
| AwsSecretsManagerPlugin._secrets_cache.put(self._secret_key, self._secret, token_expiration_ns) |
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.
Based on the way CacheMap checks for expiration:
def is_expired(self) -> bool:
return time.perf_counter_ns() > self._expiration_time_ns
This should be
| AwsSecretsManagerPlugin._secrets_cache.put(self._secret_key, self._secret, token_expiration_ns) | |
| AwsSecretsManagerPlugin._secrets_cache.put(self._secret_key, self._secret, time.perf_counter_ns() + token_expiration_ns) |
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.
Put already adds the time.perf_counter_ns()
def put(self, key: K, item: V, item_expiration_ns: int): self._cache[key] = CacheItem(item, time.perf_counter_ns() + item_expiration_ns) self._cleanup()
59dfd8b to
06c9894
Compare
# Conflicts: # docs/using-the-python-driver/using-plugins/UsingTheAwsSecretsManagerPlugin.md
06c9894 to
2df14d5
Compare
Description
The secrets manager plugin currently stores secrets with no expiry time. Users should be able to specify the amount of time a secret stays in the wrapper's cache.
Manually tested with secret cache.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.