keeper

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicate = errors.New("duplicate secret")

Functions

func Build

func Build(ctx context.Context, name string) (secrets.Keeper, error)

Build creates a secret keeper from the configuration in the context.

func CheckConfig

func CheckConfig(ctx context.Context, c *config.Config) error

CheckConfig validates the configuration for all of ghost.

func Decode

func Decode(ctx context.Context, name string) (any, error)

Decode decodes the configuration for the named secret keeper into its preferred configuration type. This is useful for tools that want to manipulate the configuration directly. This will have any secret references resolved and lookups performed.

func Exists

func Exists(ctx context.Context, name string) bool

Exists checks if the named secret keeper exists in the configuration in the context.

func PinEntry

func PinEntry(title, desc, prompt, ok string) (string, error)

PinEntry is a tool that makes it easier to display a dialog prompting the user for a password.

func StartServer

func StartServer(
	logger *log.Logger,
	kpr secrets.Keeper,
	name string,
	enforcementPeriod time.Duration,
	enforcedPolicies []string,
) error

StartServer starts the keeper server. As of this writing, it will always be configured to run in an automatically named unix socket in the system's temp directory. It will also write a pid file to the same directory.

func StopServer

func StopServer(immediacy StopImmediacy) error

StopServer stops the keeper server. The given immediacy indicates how quickly the server should be stopped.

func Validate

func Validate(ctx context.Context, name string) error

Validate checks that the configuration int he context is correct for the named secret keeper.

func WithBuilder

func WithBuilder(ctx context.Context, c *config.Config) context.Context

WithBuilder adds the secret keeper builder to the context.

Types

type ServiceStatus added in v0.3.0

type ServiceStatus struct {
	Pid               int           // the PID of the service
	Keeper            string        // the keeper the service is serving
	EnforcementPeriod time.Duration // the enforcement period
	EnforcedPolicies  []string      // the policies being enforced
}

func CheckServer added in v0.1.0

func CheckServer() (*ServiceStatus, error)

CheckServer checks if the server is alive and returns a little status structure to describe it. Returns an error if it is not.

type StopImmediacy

type StopImmediacy int

StopImmediacy is used to indicate how quickly the server should be stopped.

const (
	StopGraceful StopImmediacy = iota // stop eventually (SIGHUP)
	StopQuick                         // stop soon (SIGQUIT)
	StopNow                           // stop now (SIGKILL)
)

type Sync added in v0.2.0

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

Sync is an engine that helps with the copying of secrets between secret keepers. It organizes these copies on the basis of name, username, and location as the key values.

This works by using calls to one or more of the Add* methods to configure the secrets to sync. Then CopyTo can be used to send these secrets to another secret keeper. The DeleteAbsent will delete any secrets in the given secret keeper that have not be added using the Add* methods.

func NewSync added in v0.2.0

func NewSync() (*Sync, error)

NewSync creates a new blank object for handling sync between secret keepers.

func (*Sync) AddLocationSecret added in v0.2.0

func (s *Sync) AddLocationSecret(
	ctx context.Context,
	from secrets.Keeper,
	loc string,
	ignoreDuplicates bool,
) error

AddLocationSecret adds all the secrets in a given location to the list to be copied. If the location contains secrets with identical name and username, ErrDuplicate will be returned unless ignoreDuplicates is set to true. If ignoreDuplicates is set, the most recent secret will be kept.

func (*Sync) AddSecret added in v0.2.0

func (s *Sync) AddSecret(
	ctx context.Context,
	sec secrets.Secret,
	ignoreDuplicate bool,
) error

AddSecret adds a single secret to the list to be copied. If the secret has already been added, it will return ErrDuplicate unless ignoreDuplicate is set to true. If ignoreDuplicate is set, the more recent secret will be kept.

func (*Sync) AddSecretKeeper added in v0.2.0

func (s *Sync) AddSecretKeeper(
	ctx context.Context,
	from secrets.Keeper,
	ignoreDuplicates bool,
) error

AddSecretKeeper adds all secrets in a keeper to the destination.

If the secret keeper contains more than one secret with the same name, username, and location, the ErrDuplicate will be returned, with the Sync object now partially filled. You can set ignoreDuplicates to cause secondary secrets to be ignored. If set, the most recently modified secret will be kept.

func (*Sync) CopyTo added in v0.2.0

func (s *Sync) CopyTo(ctx context.Context, to secrets.Keeper) error

CopyTo copies all the secrets that have been added to the Sync object for copying via the Add* methods into the given keeper.

func (*Sync) DeleteAbsent added in v0.2.0

func (s *Sync) DeleteAbsent(ctx context.Context, to secrets.Keeper) error

DeleteAbsent deletes all the secrets in the destination keeper that do not exactly match the ones added to the Sync object via the Add* methods. It matches using name, username, and location.

Jump to

Keyboard shortcuts

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