secrets

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSecretNotFound        = errors.New("secret not found")
	ErrDecryptionFailed      = errors.New("decryption failed")
	ErrEncryptionFailed      = errors.New("encryption failed")
	ErrInvalidConfig         = errors.New("invalid configuration")
	ErrInvalidSecretPath     = errors.New("invalid secret path")
	ErrEncryptFailed         = errors.New("encryption failed")
	ErrDecryptFailed         = errors.New("decryption failed")
	ErrDopplerNotConfigured  = errors.New("doppler integration not configured")
	ErrInvalidSecretFormat   = errors.New("invalid secret format")
	ErrUnsupportedPlatform   = errors.New("unsupported platform")
	ErrKeyGenerationFailed   = errors.New("key generation failed")
	ErrSecretAlreadyExists   = errors.New("secret already exists")
	ErrPermissionDenied      = errors.New("permission denied")
	ErrInvalidProvider       = errors.New("invalid secret provider")
	ErrProviderNotConfigured = errors.New("provider not configured")
	ErrConfigNotFound        = errors.New("configuration not found")
)
View Source
var (
	SLogs = shared.PackageLogger("Secrets::", "🔐 Secrets Manager::")
)

Functions

func Decrypt

func Decrypt(ciphertext []byte, key []byte) ([]byte, error)

func DeriveKey

func DeriveKey(key string) ([]byte, error)

GenerateKey creates a SHA-256 hash of the provided key.

func Encrypt

func Encrypt(plaintext []byte, key []byte) ([]byte, error)

Types

type ConfigFile

type ConfigFile struct {
	EncryptedPath string
	DecryptedPath string
	Content       []byte
}

type EnvFile

type EnvFile struct {
	EncryptedPath string
	DecryptedPath string
	Content       []byte
}

type Option

type Option func(*SecretManager)

func WithConfig

func WithConfig(cfg *config.NextDeployConfig) Option

func WithKeyPath

func WithKeyPath(path string) Option

func WithProvider

func WithProvider(name string, provider SecretProvider) Option

type Secret

type Secret struct {
	Value       string `json:"value"`
	Version     int    `json:"version"`
	CreatedAt   int64  `json:"created_at"`
	ModifiedAt  int64  `json:"modified_at"`
	IsEncrypted bool   `json:"is_encrypted"`
}

type SecretManager

type SecretManager struct {
	// contains filtered or unexported fields
}

func NewSecretManager

func NewSecretManager(opts ...Option) (*SecretManager, error)

func (*SecretManager) DecryptFile

func (sm *SecretManager) DecryptFile(filename string, key []byte) (string, error)

DecryptFile decrypts a .enc file produced by encryptToFile and returns the plaintext. A wrong key or any tampering surfaces as a decryption error (GCM authentication failure).

func (*SecretManager) EncryptEnvFile

func (sm *SecretManager) EncryptEnvFile(masterKey string) (map[string]string, error)

func (*SecretManager) EncryptFile

func (sm *SecretManager) EncryptFile(filename string, key []byte) error

func (*SecretManager) ExportSecrets

func (sm *SecretManager) ExportSecrets(filePath string) error

func (*SecretManager) FlattenSecrets

func (sm *SecretManager) FlattenSecrets() map[string]string

FlattenSecrets returns all secrets as a plain map[string]string, decrypting encrypted values in-place. Suitable for cloud injection.

func (*SecretManager) GenerateMasterKey

func (sm *SecretManager) GenerateMasterKey() ([]byte, error)

func (*SecretManager) GeneratePlatformKey

func (sm *SecretManager) GeneratePlatformKey() (string, error)

func (*SecretManager) GenerateWindowsKey

func (sm *SecretManager) GenerateWindowsKey() (string, error)

func (*SecretManager) GetAppName

func (sm *SecretManager) GetAppName() string

func (*SecretManager) GetDopplerProvider

func (sm *SecretManager) GetDopplerProvider() (SecretProvider, bool)

func (*SecretManager) GetKey

func (sm *SecretManager) GetKey() string

func (*SecretManager) GetKeyOsAgnosticPath

func (sm *SecretManager) GetKeyOsAgnosticPath() string

func (*SecretManager) GetSecret

func (sm *SecretManager) GetSecret(name string) (string, error)

func (*SecretManager) ImportSecrets

func (sm *SecretManager) ImportSecrets(filePath string) error

func (*SecretManager) IsDopplerEnabled

func (sm *SecretManager) IsDopplerEnabled() bool

func (*SecretManager) IsKeyExist

func (sm *SecretManager) IsKeyExist() bool

func (*SecretManager) MigrateToProvider

func (sm *SecretManager) MigrateToProvider(providerName string) error

func (*SecretManager) PrepareSecretsContext

func (sm *SecretManager) PrepareSecretsContext() error

func (*SecretManager) RotateSecrets

func (sm *SecretManager) RotateSecrets() error

func (*SecretManager) SecureCompare

func (sm *SecretManager) SecureCompare(a, b string) bool

func (*SecretManager) SetSecret

func (sm *SecretManager) SetSecret(name, value string, encrypt bool) error

func (*SecretManager) ValidateSecret

func (sm *SecretManager) ValidateSecret(name, value string) error

type SecretProvider

type SecretProvider interface {
	GetSecret(key string) (string, error)
	SetSecret(key, value string) error
	DeleteSecret(key string) error
	ListSecrets() ([]string, error)
	Encrypt(data []byte, key string) ([]byte, error)
	Decrypt(data []byte, key string) ([]byte, error)
	GenerateMasterKey() (string, error)
	DeriveKey(key string) ([]byte, error)
	ValidateSecretFormat(secret string) error
}

Jump to

Keyboard shortcuts

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