keepass

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigType = "keepass"

ConfigType is the name of the config type for the Keepass secret keeper.

Variables

This section is empty.

Functions

func Builder

func Builder(_ context.Context, c any) (secrets.Keeper, error)

Builder builds a new Keepass secret keeper.

Types

type Config

type Config struct {
	// Path is the path to the Keepass database.
	Path string `mapstructure:"path" yaml:"path"`
	// Master is the master password to use to unlock the Keepass database.
	Master string `mapstructure:"master_password" yaml:"master_password"`
}

Config is the configuration for the Keepass secret keeper.

type Keepass

type Keepass struct {
	fssafe.LoaderSaver
	// contains filtered or unexported fields
}

Keepass is a Keeper with access to a Keepass password database.

func NewKeepass

func NewKeepass(path, master string) (*Keepass, error)

NewKeepass creates a new Keepass Keeper and returns it. If no database exists yet, it will create an empty one. It returns an error if there's a problem reading the Keepass database.

func NewKeepassNoVerify

func NewKeepassNoVerify(path, master string) (*Keepass, error)

NewKeepassNoVerify creates a new Keepass Keeper and returns it. It does not attempt to read the database or verify it is setup correctly.

func (*Keepass) CopySecret

func (k *Keepass) CopySecret(
	ctx context.Context,
	id, grp string,
) (secrets.Secret, error)

CopySecret copies the secret into an additional group in the Keepass database.

func (*Keepass) DeleteSecret

func (k *Keepass) DeleteSecret(
	ctx context.Context,
	id string,
) error

DeleteSecret removes the secret from the Keepass database.

func (*Keepass) GetSecret

func (k *Keepass) GetSecret(
	ctx context.Context,
	id string,
) (secrets.Secret, error)

GetSecret retrieves the identified secret from the Keepass database.

func (*Keepass) GetSecretsByName

func (k *Keepass) GetSecretsByName(
	ctx context.Context,
	name string,
) ([]secrets.Secret, error)

GetSecretsByName retrieves all secrets with the given name from the Keepass database.

func (*Keepass) ListLocations

func (k *Keepass) ListLocations(ctx context.Context) ([]string, error)

ListLocations gets all the group names from the Keepass database. Groups are hierarchical in the Keepass database. Each location is returned as path fully qualified path.

func (*Keepass) ListSecrets

func (k *Keepass) ListSecrets(
	ctx context.Context,
	folder string,
) ([]string, error)

ListSecrets gets the names of all secrets in the named location.

func (*Keepass) MoveSecret

func (k *Keepass) MoveSecret(
	ctx context.Context,
	id, grp string,
) (secrets.Secret, error)

MoveSecret moves the secret into a different group in the Keepass database.

func (*Keepass) SetSecret

func (k *Keepass) SetSecret(
	ctx context.Context,
	secret secrets.Secret,
) (secrets.Secret, error)

SetSecret upserts the secret into the Keepass database file.

func (*Keepass) Walker

func (k *Keepass) Walker(walkEntries bool) *KeepassWalker

Walker creates an iterator for walking through the Keepass database records.

type KeepassWalker

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

KeepassWalker represents a tool for walking Keepass records.

func (*KeepassWalker) Dir

func (w *KeepassWalker) Dir() string

Dir retrieves the name of the location of the current group as a path.

func (*KeepassWalker) Entry

func (w *KeepassWalker) Entry() *keepass.Entry

Entry retrieves the current entry to inspect during iteration.

func (*KeepassWalker) Group

func (w *KeepassWalker) Group() *keepass.Group

Group retrieves the current group to inspect during iteration.

func (*KeepassWalker) Next

func (w *KeepassWalker) Next() bool

Next returns the next record for iteration. If walkEntries was set to true, this will return true if another entry is found in the tree. Otherwise, this will return false if another group is found in the tree. Returns false if no records are left for iteration.

type Secret

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

Secret is a secrets.Secret implementation that wraps a keepass.Entry.

func (*Secret) DeleteField

func (s *Secret) DeleteField(key string)

DeleteField removes the field with the given key.

func (*Secret) Fields

func (s *Secret) Fields() map[string]string

Fields returns the fields of the Keepass entry.

func (*Secret) GetField

func (s *Secret) GetField(key string) string

GetField returns the value of the field with the given key.

func (*Secret) ID

func (s *Secret) ID() string

ID returns the UUID of the Keepass entry.

func (*Secret) LastModified

func (s *Secret) LastModified() time.Time

LastModified returns the last modification time of the Keepass entry.

func (*Secret) Location

func (s *Secret) Location() string

Location returns the full path of the location.

func (*Secret) Name

func (s *Secret) Name() string

Name returns the Title of the Keepass entry.

func (*Secret) Password

func (s *Secret) Password() string

Password returns the Password of the Keepass entry.

func (*Secret) SetField

func (s *Secret) SetField(key, value string)

SetField sets the value of the field with the given key.

func (*Secret) SetLocation

func (s *Secret) SetLocation(loc string)

SetLocation sets the location of the full path of the secret.

func (*Secret) SetName

func (s *Secret) SetName(name string)

SetName sets the Title of the Keepass entry.

func (*Secret) SetPassword

func (s *Secret) SetPassword(secret string)

SetPassword sets the Password of the Keepass entry.

func (*Secret) SetType

func (s *Secret) SetType(typ string)

SetType sets the Type of the Keepass entry.

func (*Secret) SetUrl

func (s *Secret) SetUrl(u *url.URL)

SetUrl sets the URL of the Keepass entry.

func (*Secret) SetUsername

func (s *Secret) SetUsername(username string)

SetUsername sets the Username of the Keepass entry.

func (*Secret) Type

func (s *Secret) Type() string

Type returns the Type of the Keepass entry.

func (*Secret) Url

func (s *Secret) Url() *url.URL

Url returns the URL of the Keepass entry.

func (*Secret) Username

func (s *Secret) Username() string

Username returns the Username of the Keepass entry.

Jump to

Keyboard shortcuts

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