config

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyOptions

func ApplyOptions(config *Config, options []Option) error

ApplyOptions applies all configuration options to a config

Types

type Argon2Params

type Argon2Params struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	SaltLength  uint32
	KeyLength   uint32
}

Argon2Params holds parameters for Argon2 hashing (internal config version)

func (*Argon2Params) GetIterations

func (a *Argon2Params) GetIterations() uint32

func (*Argon2Params) GetKeyLength

func (a *Argon2Params) GetKeyLength() uint32

func (*Argon2Params) GetMemory

func (a *Argon2Params) GetMemory() uint32

Interface methods for crypto package compatibility

func (*Argon2Params) GetParallelism

func (a *Argon2Params) GetParallelism() uint8

func (*Argon2Params) GetSaltLength

func (a *Argon2Params) GetSaltLength() uint32

func (*Argon2Params) Validate

func (a *Argon2Params) Validate() error

Validate checks if the Argon2 parameters are within acceptable ranges

type Config

type Config struct {
	KMSService        KeyManagementService
	KEKAlias          string
	Pepper            []byte
	PepperSecretPath  string
	Argon2Params      *Argon2Params
	KeyMetadataDB     *sql.DB
	DBPath            string
	DBFilename        string
	MetricsCollector  MetricsCollector
	ObservabilityHook ObservabilityHook
}

Config holds the complete configuration for a Crypto instance

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig creates a default configuration

type KeyManagementService

type KeyManagementService interface {
	GetKeyID(ctx context.Context, alias string) (string, error)
	CreateKey(ctx context.Context, description string) (string, error)
	EncryptDEK(ctx context.Context, keyID string, plaintext []byte) ([]byte, error)
	DecryptDEK(ctx context.Context, keyID string, ciphertext []byte) ([]byte, error)
}

KeyManagementService defines the interface for KMS operations

type MetricsCollector

type MetricsCollector = monitoring.MetricsCollector

Type aliases for interfaces from monitoring package

type ObservabilityHook

type ObservabilityHook = monitoring.ObservabilityHook

Type aliases for interfaces from monitoring package

type Option

type Option func(*Config) error

Option represents a configuration option for creating a Crypto instance

func WithArgon2Params

func WithArgon2Params(params *Argon2Params) Option

WithArgon2Params sets the Argon2 hashing parameters

func WithDBFilename

func WithDBFilename(filename string) Option

WithDBFilename sets the database filename

func WithDBPath

func WithDBPath(path string) Option

WithDBPath sets the database directory path

func WithKeyMetadataDBFilename

func WithKeyMetadataDBFilename(filename string) Option

WithKeyMetadataDBFilename sets the filename for the key metadata database within the default directory NOTE: In v0.6.0+, this function sets the DB filename but the database connection is auto-managed

func WithKeyMetadataDBPath

func WithKeyMetadataDBPath(path string) Option

WithKeyMetadataDBPath sets the full path to the key metadata database NOTE: In v0.6.0+, this function sets the DB path but the database connection is auto-managed

func WithMetricsCollector

func WithMetricsCollector(collector MetricsCollector) Option

WithMetricsCollector sets the metrics collector

func WithObservabilityHook

func WithObservabilityHook(hook ObservabilityHook) Option

WithObservabilityHook sets the observability hook

type Validator

type Validator struct{}

Validator handles configuration validation

func NewValidator

func NewValidator() *Validator

NewValidator creates a new configuration validator

func (*Validator) ValidateConfig

func (v *Validator) ValidateConfig(config *Config) error

ValidateConfig validates the complete configuration (legacy method)

func (*Validator) ValidateConfigForEnvironment added in v0.6.0

func (v *Validator) ValidateConfigForEnvironment(config *Config) error

ValidateConfigForEnvironment validates the configuration for environment-based initialization

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL