Extended configuration for views and expiration allowing both. #189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The current implementation does not allow setting both the view count and expiration at the same time. Additionally, when persistence is required, keys without expiration can flood the database. According to our requirements, we need long-living secrets, but we must ensure that they expire after a specified period.
Solution
This change introduces three new environment variables:
DEFAULT_EXPIRE
DEFAULT_VIEWS
DISABLE_MODE_SWITCH
The main goal is to maintain compatibility with the current implementation in the default configuration.
Key Changes
DEFAULT_EXPIRE
: Used when expiration is not explicitly specified. Defaults to 60 minutes if not provided.DEFAULT_VIEWS
: Applied when the advanced mode is disabled or when expiration is selected in advanced mode with the mode switch enabled (keeping its default value to 0 makes views amount unlimited as in the original implementation).DISABLE_MODE_SWITCH
: Disables the mode switch in the advanced section, allowing users to specify both a view limit and expiration time.Summary
This update improves secret management by enforcing expiration, reducing database clutter, and allowing better control over secret lifecycle through configurable defaults. Backward compatibility is preserved for default usage, with the only exception being that secrets can no longer have infinite lifespans.