secrets

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMasterKey

func GenerateMasterKey() (string, error)

GenerateMasterKey creates a 32-byte random key and returns it as a hex string.

func SaveSecrets added in v0.2.0

func SaveSecrets(jsonFile string, store map[string]string) error

Saves secrets back to the JSON file

Types

type LocalSecretStore

type LocalSecretStore struct {
	Secrets map[string]string `json:"secrets"`
	// contains filtered or unexported fields
}

Structure to store encrypted secrets in a JSON file

func NewLocalSecretStore

func NewLocalSecretStore(masterKeyHex, filename string, create bool) (*LocalSecretStore, error)

func (*LocalSecretStore) GetSecretByID

func (l *LocalSecretStore) GetSecretByID(secretID string) (string, error)

GetSecretByID decrypts the secret using the master key and returns it

func (*LocalSecretStore) ListSecrets

func (l *LocalSecretStore) ListSecrets() (map[string]string, error)

ListSecrets returns a copy of secret IDs to secrets stored in memory

func (*LocalSecretStore) RemoveSecretByID added in v0.2.0

func (l *LocalSecretStore) RemoveSecretByID(secretID string) error

RemoveSecretByID removes the specified secretID stored locally

func (*LocalSecretStore) StoreSecretByID

func (l *LocalSecretStore) StoreSecretByID(secretID, secret string) error

StoreSecretByID encrypts the secret using the master key and stores it in the JSON file

type SecretStore

type SecretStore interface {
	GetSecretByID(secretID string) (string, error)
	StoreSecretByID(secretID, secret string) error
	ListSecrets() (map[string]string, error)
	RemoveSecretByID(secretID string) error
}

func OpenStore added in v0.2.0

func OpenStore(filename string) (SecretStore, error)

openStore tries to create or open the LocalSecretStore based on the environment variable MASTER_KEY. If not found, it prints an error.

type StaticStore

type StaticStore struct {
	Username string
	Password string
}

func NewStaticStore

func NewStaticStore(username, password string) *StaticStore

NewStaticStore creates a new StaticStore with the given username and password.

func (*StaticStore) GetSecretByID

func (s *StaticStore) GetSecretByID(secretID string) (string, error)

func (*StaticStore) ListSecrets

func (s *StaticStore) ListSecrets() (map[string]string, error)

func (*StaticStore) RemoveSecretByID added in v0.2.0

func (s *StaticStore) RemoveSecretByID(secretID string) error

func (*StaticStore) StoreSecretByID

func (s *StaticStore) StoreSecretByID(secretID, secret string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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