lastpass

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigType = "lastpass"

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

Variables

View Source
var ErrTooManyRetries = errors.New("too many retries")

Functions

func Builder

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

Builder builds a new lastpass secret keeper.

Types

type Config

type Config struct {
	// Username is the username to use to log into LastPass.
	Username string `mapstructure:"username" yaml:"username"`
	// Password is the password to use to log into LastPass.
	Password string `mapstructure:"password" yaml:"password"`
}

Config is the configuration for the lastpass secret keeper.

type LastPass

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

LastPass is a secret Keeper that gets secrets from the LastPass password manager service.

func NewLastPass

func NewLastPass(ctx context.Context, username, password string) (*LastPass, error)

NewLastPass constructs and returns a new LastPass Keeper or returns an error if there was a problem during construction.

The username and password arguments are used to authenticate with LastPass.

func NewLastPassWithClient

func NewLastPassWithClient(
	lp LastPassClient,
) (*LastPass, error)

NewLastPassWithClient constructs a new LastPass Keeper with a custom LastPass client. This constructor is mostly intended for use during testing.

func (*LastPass) CopySecret

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

CopySecret copies the account from one group to another in LastPass.

func (*LastPass) DeleteSecret

func (l *LastPass) DeleteSecret(ctx context.Context, id string) error

DeleteSecret removes the account from LastPass.

func (*LastPass) GetSecret

func (l *LastPass) GetSecret(ctx context.Context, id string) (secrets.Secret, error)

GetSecret returns the secret from the Lastpass service.

func (*LastPass) GetSecretsByName

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

GetSecretsByName returns all the secrets from the LastPass service with the given name.

func (*LastPass) ListLocations

func (l *LastPass) ListLocations(ctx context.Context) ([]string, error)

ListLocations returns a list of LastPass folders.

func (*LastPass) ListSecrets

func (l *LastPass) ListSecrets(ctx context.Context, location string) ([]string, error)

ListSecrets returns a list of secrets in each folder.

func (*LastPass) MoveSecret

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

MoveSecret copies the account to a new group and deletes the old one.

func (*LastPass) SetSecret

func (l *LastPass) SetSecret(
	ctx context.Context,
	secret secrets.Secret,
) (secrets.Secret, error)

SetSecret sets the secret value in the LastPass service.

type LastPassClient

type LastPassClient interface {
	// Accounts should list secrets.
	Accounts(ctx context.Context) ([]*lastpass.Account, error)

	// Update updates a single secret.
	Update(ctx context.Context, a *lastpass.Account) error

	// Add creates a new secret.
	Add(ctx context.Context, a *lastpass.Account) error

	// Delete deletes a secret.
	Delete(ctx context.Context, a *lastpass.Account) error
}

LastPassClient defines the interface required for a LastPass client. Normally, this is fulfilled by lastpass.Client, but is handled as an interface to make testing possible without an actual LastPass account.

type Secret

type Secret struct {
	*lastpass.Account
	// contains filtered or unexported fields
}

Secret is a secrets.Secret implementation that wraps a LastPass account.

func (*Secret) Fields

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

Fields returns the LastPass account fields to be stored in the note field.

func (*Secret) GetField

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

GetField gets a LastPass account field from the note field.

func (*Secret) ID

func (s *Secret) ID() string

ID returns the LastPass account ID.

func (*Secret) LastModified

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

LastModified returns the LastPass account LastModifiedGMT.

func (*Secret) Location

func (s *Secret) Location() string

Location returns the LastPass account Group.

func (*Secret) Name

func (s *Secret) Name() string

Name returns the LastPass account name.

func (*Secret) Password

func (s *Secret) Password() string

Password returns the LastPass account password.

func (*Secret) SetField

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

SetField sets a LastPass account field in the note field.

func (*Secret) SetFields

func (s *Secret) SetFields(fields map[string]string)

SetFields sets all LastPass account field in the note field at once.

func (*Secret) SetName

func (s *Secret) SetName(name string)

SetName sets the LastPass account name.

func (*Secret) SetPassword

func (s *Secret) SetPassword(secret string)

SetPassword sets the LastPass account password.

func (*Secret) SetType

func (s *Secret) SetType(typ string)

SetType sets the LastPass account NoteType.

func (*Secret) SetUrl

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

SetUrl sets the LastPass account URL.

func (*Secret) SetUsername

func (s *Secret) SetUsername(username string)

SetUsername sets the LastPass account username.

func (*Secret) Type

func (s *Secret) Type() string

Type returns the LastPass account NoteType.

func (*Secret) Url

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

Url returns the LastPass account URL.

func (*Secret) Username

func (s *Secret) Username() string

Username returns the LastPass account username.

Jump to

Keyboard shortcuts

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