Documentation
¶
Index ¶
- Constants
- func EnqueueForceSyncKeysToDatabase(ctx context.Context, redis apredis.Client, ac apasynq.Client, ...)
- func EnqueueGenerateDataEncryptionKeysToDatabase(ctx context.Context, ac apasynq.Client, logger *slog.Logger)
- func GenerateDataEncryptionKeysToDatabase(ctx context.Context, cfg iconfig.C, db database.DB, logger *slog.Logger, ...) error
- func NewGenerateDataEncryptionKeysTask() *asynq.Task
- func NewReencryptAllTask() *asynq.Task
- func NewSyncKeysToDatabaseTask() *asynq.Task
- func SyncKeysToDatabase(ctx context.Context, cfg iconfig.C, db database.DB, logger *slog.Logger, ...) error
- type DataEncryptionKeyTelemetry
- type E
- type EncryptServiceTaskHandler
- type EncryptServiceTaskHandlerOption
- type GenerateDataEncryptionKeysOption
- type NamespacedEntity
- type SyncKeysOption
Constants ¶
const (
TaskTypeGenerateDataEncryptionKeys = "encrypt:generate_data_encryption_keys"
)
const (
TaskTypeReencryptAll = "encrypt:reencrypt_all"
)
const (
TaskTypeSyncKeysToDatabase = "encrypt:sync_keys_to_database"
)
Variables ¶
This section is empty.
Functions ¶
func EnqueueForceSyncKeysToDatabase ¶
func EnqueueForceSyncKeysToDatabase(ctx context.Context, redis apredis.Client, ac apasynq.Client, logger *slog.Logger)
EnqueueForceSyncKeysToDatabase clears the sync sentinel and enqueues a sync task immediately. The mutex inside the sync function prevents concurrent syncs.
func EnqueueGenerateDataEncryptionKeysToDatabase ¶
func EnqueueGenerateDataEncryptionKeysToDatabase(ctx context.Context, ac apasynq.Client, logger *slog.Logger)
EnqueueGenerateDataEncryptionKeysToDatabase schedules immediate DEK reconciliation. This is used after creating new key material so the key gets a current DEK without waiting for the periodic task.
func GenerateDataEncryptionKeysToDatabase ¶
func GenerateDataEncryptionKeysToDatabase( ctx context.Context, cfg iconfig.C, db database.DB, logger *slog.Logger, redis apredis.Client, opts ...GenerateDataEncryptionKeysOption, ) error
GenerateDataEncryptionKeysToDatabase reconciles current DEKs for configured data-encryption keys without constructing the runtime encryption service.
func NewReencryptAllTask ¶
Types ¶
type DataEncryptionKeyTelemetry ¶
type DataEncryptionKeyTelemetry struct {
// contains filtered or unexported fields
}
DataEncryptionKeyTelemetry owns OTel metrics emitted by the encrypt package. A zero-value or nil instance is safe and emits nothing.
func NewDataEncryptionKeyTelemetry ¶
func NewDataEncryptionKeyTelemetry( providers *aptelemetry.Providers, cfg *sconfig.Telemetry, ) (*DataEncryptionKeyTelemetry, error)
type E ¶
type E interface {
// EncryptGlobal encrypts the given data using the global encryption key.
EncryptGlobal(ctx context.Context, data []byte) (encfield.EncryptedField, error)
// EncryptStringGlobal encrypts the given data using the global encryption key.
EncryptStringGlobal(ctx context.Context, data string) (encfield.EncryptedField, error)
// EncryptForNamespace encrypts the given data using the namespace encryption key.
EncryptForNamespace(ctx context.Context, namespacePath string, data []byte) (encfield.EncryptedField, error)
// EncryptStringForNamespace encrypts the given data using the namespace encryption key.
EncryptStringForNamespace(ctx context.Context, namespacePath string, data string) (encfield.EncryptedField, error)
// EncryptKeyForNamespace is a special variant for key entities only. It follows special
// rules about which encryption key to use to avoid cycles in the graph.
EncryptKeyForNamespace(ctx context.Context, namespacePath string, keyData []byte) (encfield.EncryptedField, error)
// EncryptForEntity encrypts the given data using the key for namespace of the entity
EncryptForEntity(ctx context.Context, entity NamespacedEntity, data []byte) (encfield.EncryptedField, error)
// EncryptStringForEntity encrypts the given data using the key for namespace of the entity
EncryptStringForEntity(ctx context.Context, enity NamespacedEntity, data string) (encfield.EncryptedField, error)
// Decrypt decrypts the given encrypted field. It uses the metadata in the encrypted field to identify the
// appropriate DEK to use for decryption.
Decrypt(ctx context.Context, ef encfield.EncryptedField) ([]byte, error)
// DecryptString decrypts the given encrypted field to a string. It uses the metadata in the encrypted
// to identify the appropriate DEK to use for decryption.
DecryptString(ctx context.Context, ef encfield.EncryptedField) (string, error)
// ReEncryptField decrypts the given encrypted field and re-encrypts it with the specified
// target DEK. If the field is already encrypted with the target DEK, it is
// returned unchanged.
ReEncryptField(ctx context.Context, ef encfield.EncryptedField, targetDEKId apid.ID) (encfield.EncryptedField, error)
// SyncKeysFromDbToMemory forces a refresh of the in-memory key caches from the database.
SyncKeysFromDbToMemory(ctx context.Context) error
// Start launches the background key sync goroutine.
Start()
// Shutdown stops the background key sync goroutine and waits for it to exit.
Shutdown()
}
func NewEncryptService ¶
func NewFakeEncryptService ¶
NewFakeEncryptService returns an encrypt service that does not encrypt or decrypt anything.
type EncryptServiceTaskHandler ¶
type EncryptServiceTaskHandler struct {
// contains filtered or unexported fields
}
func (*EncryptServiceTaskHandler) GetCronTasks ¶
func (h *EncryptServiceTaskHandler) GetCronTasks() []*asynq.PeriodicTaskConfig
func (*EncryptServiceTaskHandler) RegisterTasks ¶
func (h *EncryptServiceTaskHandler) RegisterTasks(mux *asynq.ServeMux)
type EncryptServiceTaskHandlerOption ¶
type EncryptServiceTaskHandlerOption func(*EncryptServiceTaskHandler)
func WithDataEncryptionKeyTelemetry ¶
func WithDataEncryptionKeyTelemetry(tel *DataEncryptionKeyTelemetry) EncryptServiceTaskHandlerOption
type GenerateDataEncryptionKeysOption ¶
type GenerateDataEncryptionKeysOption func(*generateDataEncryptionKeysOptions)
func WithGenerateDataEncryptionKeysTelemetry ¶
func WithGenerateDataEncryptionKeysTelemetry(tel *DataEncryptionKeyTelemetry) GenerateDataEncryptionKeysOption
type NamespacedEntity ¶
type NamespacedEntity interface {
GetNamespace() string
}
type SyncKeysOption ¶
type SyncKeysOption func(*syncKeysOptions)
func WithSyncKeysTelemetry ¶
func WithSyncKeysTelemetry(tel *DataEncryptionKeyTelemetry) SyncKeysOption