secret

package
v0.0.0-...-7447204 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyKey   = errors.New("key cannot be empty")
	ErrLongKey    = errors.New("key is too long")
	ErrInvalidKey = errors.New("invalid key")

	ErrEmptyValue = errors.New("value cannot be empty")
	ErrLongValue  = errors.New("value is too long")

	ErrInvalidSharedKey = errors.New("invalid shared key")
)

Functions

func ValidateKey

func ValidateKey(key string) (bool, error)

ValidateKey verifies if the input secret's key is valid, returning an error if invalid

func ValidateValue

func ValidateValue(value []byte) error

ValidateValue verifies if the input secret's value is valid, returning an error if invalid

Types

type Repository

type Repository interface {
	// Create will create (or overwrite) the secret identified by `s.Key`, for user `username`,
	// returning its ID and an error
	Create(ctx context.Context, username string, s *Secret) (uint64, error)
	// Get fetches a secret identified by `key` for user `username`. Returns a secret and an error
	Get(ctx context.Context, username string, key string) (*Secret, error)
	// List returns all secrets belonging to user `username`, and an error
	List(ctx context.Context, username string) ([]*Secret, error)
	// Delete removes the secret identified by `key`, for user `username`. Returns an error
	Delete(ctx context.Context, username string, key string) error
}

Repository describes the actions exposed by the secrets store

func WithTrace

func WithTrace(r Repository) Repository

type Secret

type Secret struct {
	ID        uint64    `json:"id"`
	Key       string    `json:"key"`
	Value     string    `json:"value"`
	CreatedAt time.Time `json:"created_at"`
}

Secret is a key-value pair where they Key is string type and Value is a slice of bytes. Secrets are encrypted then stored with a user-scoped private key

Jump to

Keyboard shortcuts

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