Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
sreya committed Oct 15, 2024
commit 50bb6e85f0f63bac1925b6f3790351c8958620ad
16 changes: 8 additions & 8 deletions coderd/cryptokeys/dbkeycache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type CryptoKeyCache struct {
refreshCancel context.CancelFunc
fetcher Fetcher
logger slog.Logger
feature database.CryptoKeyFeature
feature codersdk.CryptoKeyFeature

mu sync.Mutex
keys map[int32]codersdk.CryptoKey
Expand All @@ -65,23 +65,23 @@ func WithDBCacheClock(clock quartz.Clock) DBCacheOption {

// NewSigningCache creates a new DBCache. Close should be called to
// release resources associated with its internal timer.
func NewSigningCache(ctx context.Context, logger slog.Logger, fetcher Fetcher, feature database.CryptoKeyFeature, opts ...func(*CryptoKeyCache)) (SigningKeycache, error) {
func NewSigningCache(ctx context.Context, logger slog.Logger, fetcher Fetcher, feature codersdk.CryptoKeyFeature, opts ...func(*CryptoKeyCache)) (SigningKeycache, error) {
if !isSigningKeyFeature(feature) {
return nil, ErrInvalidFeature
}

return newDBCache(ctx, logger, fetcher, feature, opts...)
}

func NewEncryptionCache(ctx context.Context, logger slog.Logger, fetcher Fetcher, feature database.CryptoKeyFeature, opts ...func(*CryptoKeyCache)) (EncryptionKeycache, error) {
func NewEncryptionCache(ctx context.Context, logger slog.Logger, fetcher Fetcher, feature codersdk.CryptoKeyFeature, opts ...func(*CryptoKeyCache)) (EncryptionKeycache, error) {
if !isEncryptionKeyFeature(feature) {
return nil, ErrInvalidFeature
}

return newDBCache(ctx, logger, fetcher, feature, opts...)
}

func newDBCache(ctx context.Context, logger slog.Logger, fetcher Fetcher, feature database.CryptoKeyFeature, opts ...func(*CryptoKeyCache)) (*CryptoKeyCache, error) {
func newDBCache(ctx context.Context, logger slog.Logger, fetcher Fetcher, feature codersdk.CryptoKeyFeature, opts ...func(*CryptoKeyCache)) (*CryptoKeyCache, error) {
cache := &CryptoKeyCache{
clock: quartz.NewReal(),
logger: logger,
Expand Down Expand Up @@ -178,13 +178,13 @@ func (d *CryptoKeyCache) VerifyingKey(ctx context.Context, sequence string) (int
return key.Secret, nil
}

func isEncryptionKeyFeature(feature database.CryptoKeyFeature) bool {
return feature == database.CryptoKeyFeatureWorkspaceApps
func isEncryptionKeyFeature(feature codersdk.CryptoKeyFeature) bool {
return feature == codersdk.CryptoKeyFeatureWorkspaceApp
}

func isSigningKeyFeature(feature database.CryptoKeyFeature) bool {
func isSigningKeyFeature(feature codersdk.CryptoKeyFeature) bool {
switch feature {
case database.CryptoKeyFeatureTailnetResume, database.CryptoKeyFeatureOidcConvert:
case codersdk.CryptoKeyFeatureTailnetResume, codersdk.CryptoKeyFeatureOIDCConvert:
return true
default:
return false
Expand Down
Loading