Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add cache abstraction for fetching signing keys #14777

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

Merged
merged 15 commits into from
Oct 1, 2024
Merged

Conversation

sreya
Copy link
Collaborator

@sreya sreya commented Sep 24, 2024

This PR adds the database implementation for fetching and caching keys used for JWT signing. It's been merged into the keyrotate pkg and renamed to cryptokeys since they're coupled concepts. Given the size of the PR, an additional PR will be added for the wsproxy implementation.

@sreya sreya changed the title feat: add keychain abstraction for fetching encryption keys feat: add keychain abstraction for fetching signing keys Sep 24, 2024
@sreya sreya marked this pull request as ready for review September 24, 2024 01:57
@sreya sreya changed the title feat: add keychain abstraction for fetching signing keys feat: add cache abstraction for fetching signing keys Sep 24, 2024
- Simplify naming by renaming `DBKeyCache` to `DBCache`.
- Introduce `DBCacheOption` for flexible clock configuration.
- Ensure consistent clock handling across the methods.
Refactored the CryptoKey handling logic to leverage the codersdk
package. This enhances consistency and modularity by centralizing
CryptoKey management and related operations. The refactoring also
includes renaming functions to better reflect their functionality
and using the db2sdk package for database to SDK conversions.
- Simplifies conversion and improves consistency by using
  a common package for translating database keys to SDK keys.
- Improves test reliability and code maintainability by centralizing
  the conversion process.
@sreya sreya requested a review from spikecurtis September 26, 2024 22:37
Copy link
Contributor

@spikecurtis spikecurtis left a comment

Choose a reason for hiding this comment

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

You don't have to convert all the times to UTC. Go handles timezones just fine without this.

@sreya sreya requested a review from spikecurtis September 30, 2024 01:45
sreya added 2 commits October 1, 2024 06:34
Introduce a timer-based cache invalidation system in DBCache to enhance reliability. The new implementation minimizes cache invalidation race conditions during key fetching, ensuring consistent cache state management. Additions include a 'Close' method for releasing resources, such as timers, and test improvements for timer behavior validation.
@sreya sreya requested a review from spikecurtis October 1, 2024 07:00
Introduce `closed` state to the DBCache to ensure operations such
as Verifying and Signing are safely terminated when the cache is
closed. This update prevents resource access and ensures proper
shutdown sequences, enhancing system reliability.
@sreya sreya requested a review from spikecurtis October 1, 2024 15:15
Copy link
Contributor

@spikecurtis spikecurtis left a comment

Choose a reason for hiding this comment

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

I don't need to review again, but you need to fix the re-checking of d.close when you release the read lock and acquire the write lock.

@sreya sreya merged commit 21b92ef into main Oct 1, 2024
28 of 30 checks passed
@sreya sreya deleted the jon/keychain branch October 1, 2024 16:04
@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2024
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.

2 participants