Documentation
¶
Index ¶
- Variables
- func DeriveEncryptionKey(passphrase, sal string) (string, string, error)
- func GenerateEncryptionKey() (string, error)
- func New(id string, opts ...Option) (Provider, *Config, error)
- func SaveConfigJSON(config Config, path string) error
- func ValidateEncryptionKey(key string) error
- func ValidateSecretKey(reference string) error
- type AES256Vault
- func (v *AES256Vault) Close() error
- func (v *AES256Vault) DeleteSecret(key string) error
- func (v *AES256Vault) GetSecret(key string) (Secret, error)
- func (v *AES256Vault) HasSecret(key string) (bool, error)
- func (v *AES256Vault) ID() string
- func (v *AES256Vault) ListSecrets() ([]string, error)
- func (v *AES256Vault) Metadata() Metadata
- func (v *AES256Vault) SetSecret(key string, secret Secret) error
- type AESState
- type AesConfig
- type AgeConfig
- type AgeState
- type AgeVault
- func (v *AgeVault) AddRecipient(publicKey string) error
- func (v *AgeVault) Close() error
- func (v *AgeVault) DeleteSecret(key string) error
- func (v *AgeVault) GetSecret(key string) (Secret, error)
- func (v *AgeVault) HasSecret(key string) (bool, error)
- func (v *AgeVault) ID() string
- func (v *AgeVault) ListRecipients() ([]string, error)
- func (v *AgeVault) ListSecrets() ([]string, error)
- func (v *AgeVault) Metadata() Metadata
- func (v *AgeVault) RemoveRecipient(publicKey string) error
- func (v *AgeVault) SetSecret(key string, value Secret) error
- type CommandConfig
- type Config
- type ExternalConfig
- type ExternalVaultProvider
- func (v *ExternalVaultProvider) Close() error
- func (v *ExternalVaultProvider) DeleteSecret(key string) error
- func (v *ExternalVaultProvider) GetSecret(key string) (Secret, error)
- func (v *ExternalVaultProvider) HasSecret(key string) (bool, error)
- func (v *ExternalVaultProvider) ID() string
- func (v *ExternalVaultProvider) ListSecrets() ([]string, error)
- func (v *ExternalVaultProvider) Metadata() Metadata
- func (v *ExternalVaultProvider) SetExecutionFunc(...)
- func (v *ExternalVaultProvider) SetSecret(key string, value Secret) error
- type IdentityResolver
- type IdentitySource
- type KeyResolver
- type KeySource
- type KeyringConfig
- type KeyringVault
- func (v *KeyringVault) Close() error
- func (v *KeyringVault) DeleteSecret(key string) error
- func (v *KeyringVault) GetSecret(key string) (Secret, error)
- func (v *KeyringVault) HasSecret(key string) (bool, error)
- func (v *KeyringVault) ID() string
- func (v *KeyringVault) ListSecrets() ([]string, error)
- func (v *KeyringVault) Metadata() Metadata
- func (v *KeyringVault) SetSecret(key string, secret Secret) error
- type Metadata
- type Option
- func WithAESKeyFromEnv(envVar string) Option
- func WithAESKeyFromFile(path string) Option
- func WithAESPath(path string) Option
- func WithAgeIdentityFromEnv(envVar string) Option
- func WithAgeIdentityFromFile(path string) Option
- func WithAgePath(path string) Option
- func WithAgeRecipients(recipients ...string) Option
- func WithExternalConfig(cfg *ExternalConfig) Option
- func WithKeyringService(service string) Option
- func WithLocalPath(path string) Option
- func WithProvider(provider ProviderType) Option
- func WithUnencryptedPath(path string) Option
- type Provider
- type ProviderType
- type RecipientManager
- type Secret
- type SecretValue
- type SecureBytes
- type UnencryptedConfig
- type UnencryptedState
- type UnencryptedVault
- func (v *UnencryptedVault) Close() error
- func (v *UnencryptedVault) DeleteSecret(key string) error
- func (v *UnencryptedVault) GetSecret(key string) (Secret, error)
- func (v *UnencryptedVault) HasSecret(key string) (bool, error)
- func (v *UnencryptedVault) ID() string
- func (v *UnencryptedVault) ListSecrets() ([]string, error)
- func (v *UnencryptedVault) Metadata() Metadata
- func (v *UnencryptedVault) SetSecret(key string, secret Secret) error
- type VaultPathError
Constants ¶
This section is empty.
Variables ¶
var ( ErrSecretNotFound = errors.New("secret not found") ErrInvalidKey = errors.New("invalid secret key") ErrNoAccess = errors.New("access denied") ErrInvalidConfig = errors.New("invalid configuration") ErrVaultNotFound = errors.New("vault not found") ErrDecryptionFailed = errors.New("decryption failed") ErrInvalidRecipient = errors.New("invalid recipient") ErrPathNotSecure = errors.New("path is not secure") )
var (
DefaultVaultKeyEnv = "VAULT_KEY"
)
Functions ¶
func DeriveEncryptionKey ¶
DeriveEncryptionKey derives an AES encryption key from a passphrase
func GenerateEncryptionKey ¶
GenerateEncryptionKey generates a new AES encryption key
func SaveConfigJSON ¶
SaveConfigJSON saves the vault configuration to a file in JSON format
func ValidateEncryptionKey ¶
ValidateEncryptionKey checks if a key is valid by attempting to encrypt/decrypt test data
func ValidateSecretKey ¶
Types ¶
type AES256Vault ¶
type AES256Vault struct {
// contains filtered or unexported fields
}
AES256Vault manages operations on an instance of a local vault backed by AES256 symmetric encryption.
func NewAES256Vault ¶
func NewAES256Vault(cfg *Config) (*AES256Vault, error)
func (*AES256Vault) Close ¶
func (v *AES256Vault) Close() error
func (*AES256Vault) DeleteSecret ¶
func (v *AES256Vault) DeleteSecret(key string) error
func (*AES256Vault) ID ¶
func (v *AES256Vault) ID() string
func (*AES256Vault) ListSecrets ¶
func (v *AES256Vault) ListSecrets() ([]string, error)
func (*AES256Vault) Metadata ¶
func (v *AES256Vault) Metadata() Metadata
type AESState ¶
type AESState struct {
Metadata `yaml:"metadata"`
Version int `json:"version"`
ID string `yaml:"id"`
Secrets map[string]string `yaml:"secrets"`
}
AESState represents the state of the local AES256 vault.
type AesConfig ¶
type AesConfig struct {
// Storage location for the vault file
StoragePath string `json:"storage_path"`
// DEK sources for decryption (in order of preference)
KeySource []KeySource `json:"key_sources,omitempty"`
}
AesConfig contains local (AES256-based) vault configuration
type AgeConfig ¶
type AgeConfig struct {
// Storage location for the vault file
StoragePath string `json:"storage_path"`
// Identity sources for decryption (in order of preference)
IdentitySources []IdentitySource `json:"identity_sources,omitempty"`
// Recipients who can decrypt secrets
Recipients []string `json:"recipients,omitempty"`
}
AgeConfig contains local (age-based) vault configuration
type AgeState ¶
type AgeState struct {
Metadata `json:"metadata"`
Version int `json:"version"`
ID string `json:"id"`
Recipients []string `json:"recipients"`
Secrets map[string]string `json:"secrets"`
}
AgeState represents the state of the local age vault
type AgeVault ¶
type AgeVault struct {
// contains filtered or unexported fields
}
AgeVault manages operations on an instance of a local vault backed by age encryption.
func NewAgeVault ¶
func (*AgeVault) AddRecipient ¶
func (*AgeVault) DeleteSecret ¶
func (*AgeVault) ListRecipients ¶
func (*AgeVault) ListSecrets ¶
func (*AgeVault) RemoveRecipient ¶
type CommandConfig ¶ added in v0.2.0
type CommandConfig struct {
// CommandTemplate for building command arguments
CommandTemplate string `json:"cmd"`
// OutputTemplate for parsing command output
OutputTemplate string `json:"output,omitempty"`
// InputTemplate for providing input to the command
InputTemplate string `json:"input,omitempty"`
}
CommandConfig represents a command template to be executed with its arguments
type Config ¶
type Config struct {
ID string `json:"id"`
Type ProviderType `json:"type"`
Age *AgeConfig `json:"age,omitempty"`
Aes *AesConfig `json:"aes,omitempty"`
External *ExternalConfig `json:"external,omitempty"`
Keyring *KeyringConfig `json:"keyring,omitempty"`
Unencrypted *UnencryptedConfig `json:"unencrypted,omitempty"`
}
func LoadConfigJSON ¶
LoadConfigJSON loads the vault configuration from a file in JSON format
type ExternalConfig ¶
type ExternalConfig struct {
// Get CommandConfig for the get operation
Get CommandConfig `json:"get,omitempty"`
// Set CommandConfig for the set operation
Set CommandConfig `json:"set,omitempty"`
// Delete CommandConfig for the delete operation
Delete CommandConfig `json:"delete,omitempty"`
// List CommandConfig for the list operation
List CommandConfig `json:"list,omitempty"`
ListSeparator string `json:"separator,omitempty"`
// Exists CommandConfig for the exists operation
Exists CommandConfig `json:"exists,omitempty"`
// Metadata CommandConfig for the metadata operation
Metadata CommandConfig `json:"metadata,omitempty"`
// Environment variables for commands
Environment map[string]string `json:"environment,omitempty"`
// Timeout duration string for command execution
Timeout string `json:"timeout,omitempty"`
// WorkingDir for command execution
WorkingDir string `json:"working_dir,omitempty"`
}
ExternalConfig contains external (cli command-based) vault configuration
func (*ExternalConfig) Validate ¶
func (c *ExternalConfig) Validate() error
type ExternalVaultProvider ¶
type ExternalVaultProvider struct {
// contains filtered or unexported fields
}
func NewExternalVaultProvider ¶ added in v0.2.0
func NewExternalVaultProvider(cfg *Config) (*ExternalVaultProvider, error)
func (*ExternalVaultProvider) Close ¶
func (v *ExternalVaultProvider) Close() error
func (*ExternalVaultProvider) DeleteSecret ¶
func (v *ExternalVaultProvider) DeleteSecret(key string) error
func (*ExternalVaultProvider) GetSecret ¶
func (v *ExternalVaultProvider) GetSecret(key string) (Secret, error)
func (*ExternalVaultProvider) HasSecret ¶
func (v *ExternalVaultProvider) HasSecret(key string) (bool, error)
func (*ExternalVaultProvider) ID ¶
func (v *ExternalVaultProvider) ID() string
func (*ExternalVaultProvider) ListSecrets ¶
func (v *ExternalVaultProvider) ListSecrets() ([]string, error)
func (*ExternalVaultProvider) Metadata ¶ added in v0.2.0
func (v *ExternalVaultProvider) Metadata() Metadata
func (*ExternalVaultProvider) SetExecutionFunc ¶ added in v0.2.0
type IdentityResolver ¶
type IdentityResolver struct {
// contains filtered or unexported fields
}
func NewIdentityResolver ¶
func NewIdentityResolver(sources []IdentitySource) *IdentityResolver
func (*IdentityResolver) ResolveIdentities ¶
func (r *IdentityResolver) ResolveIdentities() ([]age.Identity, error)
type IdentitySource ¶
type IdentitySource struct {
// Type of identity source
// Must be one of: "env", "file"
Type string `json:"type"`
// Path to the identity file (for "file" type)
Path string `json:"fullPath,omitempty"`
// Environment variable name (for "env" type)
Name string `json:"name,omitempty"`
}
IdentitySource represents a source for the local vault identity keys
type KeyResolver ¶
type KeyResolver struct {
// contains filtered or unexported fields
}
func NewKeyResolver ¶
func NewKeyResolver(sources []KeySource) *KeyResolver
func (*KeyResolver) ResolveKeys ¶
func (r *KeyResolver) ResolveKeys() ([]string, error)
func (*KeyResolver) TryDecrypt ¶
func (r *KeyResolver) TryDecrypt(encryptedData string) (string, string, error)
type KeySource ¶
type KeySource struct {
// Type of data encryption key source
// Must be one of: "env", "file"
Type string `json:"type"`
// Path to the identity file (for "file" type)
Path string `json:"fullPath,omitempty"`
// Environment variable name (for "env" type)
Name string `json:"name,omitempty"`
}
KeySource represents a source for the local vault encryption keys
type KeyringConfig ¶ added in v0.2.0
type KeyringConfig struct {
// Service name used for keyring operations
Service string `json:"service"`
}
KeyringConfig contains keyring vault configuration
func (*KeyringConfig) Validate ¶ added in v0.2.0
func (c *KeyringConfig) Validate() error
type KeyringVault ¶ added in v0.2.0
type KeyringVault struct {
// contains filtered or unexported fields
}
KeyringVault manages operations on a keyring-based vault that stores secrets in the system keyring.
func NewKeyringVault ¶ added in v0.2.0
func NewKeyringVault(cfg *Config) (*KeyringVault, error)
func (*KeyringVault) Close ¶ added in v0.2.0
func (v *KeyringVault) Close() error
func (*KeyringVault) DeleteSecret ¶ added in v0.2.0
func (v *KeyringVault) DeleteSecret(key string) error
func (*KeyringVault) GetSecret ¶ added in v0.2.0
func (v *KeyringVault) GetSecret(key string) (Secret, error)
func (*KeyringVault) HasSecret ¶ added in v0.2.0
func (v *KeyringVault) HasSecret(key string) (bool, error)
func (*KeyringVault) ID ¶ added in v0.2.0
func (v *KeyringVault) ID() string
func (*KeyringVault) ListSecrets ¶ added in v0.2.0
func (v *KeyringVault) ListSecrets() ([]string, error)
func (*KeyringVault) Metadata ¶ added in v0.2.0
func (v *KeyringVault) Metadata() Metadata
type Option ¶
type Option func(*Config)
func WithAESKeyFromEnv ¶
WithAESKeyFromEnv specifies to retrieve the AES key from an environment variable
func WithAESKeyFromFile ¶
WithAESKeyFromFile specifies to retrieve the AES key from a file
func WithAgeIdentityFromEnv ¶
WithAgeIdentityFromEnv specifies to retrieve the age identity from an environment variable
func WithAgeIdentityFromFile ¶
WithAgeIdentityFromFile specifies to retrieve the age identity from a file
func WithAgeRecipients ¶
WithAgeRecipients sets the recipients for age vaults
func WithExternalConfig ¶
func WithExternalConfig(cfg *ExternalConfig) Option
WithExternalConfig sets the external vault configuration. FOR TESTING PURPOSES ONLY. TODO: break this down when the external provider is fully implemented
func WithKeyringService ¶ added in v0.2.0
WithKeyringService sets the keyring service name
func WithLocalPath ¶
WithLocalPath sets the local vault storage path (works for Age, AES, and Unencrypted based on provider type)
func WithProvider ¶
func WithProvider(provider ProviderType) Option
WithProvider sets the vault provider type
func WithUnencryptedPath ¶ added in v0.2.0
WithUnencryptedPath sets the unencrypted vault storage path
type Provider ¶
type Provider interface {
GetSecret(key string) (Secret, error)
SetSecret(key string, value Secret) error
DeleteSecret(key string) error
ListSecrets() ([]string, error)
HasSecret(key string) (bool, error)
// ID returns a unique identifier for this vault instance
ID() string
// Metadata returns vault metadata such as creation time
Metadata() Metadata
Close() error
}
type ProviderType ¶
type ProviderType string
const ( ProviderTypeAES256 ProviderType = "aes256" ProviderTypeAge ProviderType = "age" ProviderTypeExternal ProviderType = "external" ProviderTypeKeyring ProviderType = "keyring" ProviderTypeUnencrypted ProviderType = "unencrypted" )
type RecipientManager ¶
type RecipientManager interface {
AddRecipient(identity string) error
RemoveRecipient(identity string) error
ListRecipients() ([]string, error)
}
func HasRecipientManagement ¶
func HasRecipientManagement(v Provider) (RecipientManager, bool)
type Secret ¶
type Secret interface {
// PlainTextString returns the decrypted value as a string
PlainTextString() string
// String returns a masked representation for display
String() string
// Bytes returns the raw byte representation of the secret
Bytes() []byte
// Zero securely clears the secret from memory
Zero()
}
type SecretValue ¶
type SecretValue struct {
// contains filtered or unexported fields
}
func NewSecretValue ¶
func NewSecretValue(value []byte) *SecretValue
func (*SecretValue) Bytes ¶
func (s *SecretValue) Bytes() []byte
func (*SecretValue) PlainTextString ¶
func (s *SecretValue) PlainTextString() string
func (*SecretValue) String ¶
func (s *SecretValue) String() string
func (*SecretValue) Zero ¶
func (s *SecretValue) Zero()
type SecureBytes ¶
type SecureBytes []byte
SecureBytes is a wrapper around []byte that provides secure memory handling
func (SecureBytes) Copy ¶
func (s SecureBytes) Copy() SecureBytes
Copy creates a secure copy of the bytes
type UnencryptedConfig ¶ added in v0.2.0
type UnencryptedConfig struct {
// Storage location for the vault file
StoragePath string `json:"storage_path"`
}
UnencryptedConfig contains unencrypted (plain text) vault configuration
func (*UnencryptedConfig) Validate ¶ added in v0.2.0
func (c *UnencryptedConfig) Validate() error
type UnencryptedState ¶ added in v0.2.0
type UnencryptedState struct {
Metadata `json:"metadata"`
Version int `json:"version"`
ID string `json:"id"`
Secrets map[string]string `json:"secrets"`
}
UnencryptedState represents the state of the unencrypted vault.
type UnencryptedVault ¶ added in v0.2.0
type UnencryptedVault struct {
// contains filtered or unexported fields
}
UnencryptedVault manages operations on an instance of an unencrypted vault that stores secrets in JSON format.
func NewUnencryptedVault ¶ added in v0.2.0
func NewUnencryptedVault(cfg *Config) (*UnencryptedVault, error)
func (*UnencryptedVault) Close ¶ added in v0.2.0
func (v *UnencryptedVault) Close() error
func (*UnencryptedVault) DeleteSecret ¶ added in v0.2.0
func (v *UnencryptedVault) DeleteSecret(key string) error
func (*UnencryptedVault) GetSecret ¶ added in v0.2.0
func (v *UnencryptedVault) GetSecret(key string) (Secret, error)
func (*UnencryptedVault) HasSecret ¶ added in v0.2.0
func (v *UnencryptedVault) HasSecret(key string) (bool, error)
func (*UnencryptedVault) ID ¶ added in v0.2.0
func (v *UnencryptedVault) ID() string
func (*UnencryptedVault) ListSecrets ¶ added in v0.2.0
func (v *UnencryptedVault) ListSecrets() ([]string, error)
func (*UnencryptedVault) Metadata ¶ added in v0.2.0
func (v *UnencryptedVault) Metadata() Metadata
type VaultPathError ¶
func NewVaultPathError ¶
func NewVaultPathError(path string) *VaultPathError
func (*VaultPathError) Error ¶
func (e *VaultPathError) Error() string
func (*VaultPathError) Unwrap ¶
func (e *VaultPathError) Unwrap() error