lastpass

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2017 License: MIT Imports: 18 Imported by: 1

README

LastPass Go API




This is an unofficial LastPass API.

Check out lastpass/lastpass-cli for an Official LastPass product

This is a port of the Ruby LastPass API.

Features

  • Create/Update accounts
  • Delete accounts
  • Get accounts
  • Multi-factor authentication

Installation

$ go get github.com/while-loop/lastpass-go

Usage

Example Usages

lp, _ := lastpass.New(email, password)
accs, _ := lp.GetAccounts()
for _, account := range accs {
	fmt.Println(account.Username, account.Password)
}
With Multi-factor Auth
lp, err := New(email, password, WithMultiFactor("5412548"))
accs, _ := lp.GetAccounts()
for _, account := range accs {
	fmt.Println(account.Username, account.Password)
}

TODO

These are future plans for the project, feel free fork/pr these features if I don't get to them in time.

  • Shared groups
  • Secured notes

Changelog

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

CHANGELOG.md

License

lastpass-go is licensed under the MIT license. See LICENSE for details.

Note that this repository includes code of ecb (Electronic Code Block) provided by Go Authors.

Original Author

Yasuhiro Matsumoto (a.k.a mattn)

Current Author

Anthony Alves

Documentation

Index

Constants

View Source
const (
	// Account fields
	Id Field = iota
	Name
	Url
	Username

	// Match function types
	CaseSensitive SearchMethod = iota
	CaseInsensitive
	Regex
	SubstringSensitive
	SubstringInsensitive
)

Variables

View Source
var (
	ErrInvalidPassword       = fmt.Errorf("invalid password")
	ErrInvalidEmail          = fmt.Errorf("invalid username or password")
	ErrInvalidGoogleAuthCode = fmt.Errorf("googleauthfailed")
	ErrInvalidYubiKey        = fmt.Errorf("yubikeyrestricted")
)
View Source
var (
	ErrAccountNotFound = fmt.Errorf("account not found")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	Username string `json:"username"`
	Password string `json:"password"`
	Url      string `json:"url"`
	Group    string `json:"group"`
	Notes    string `json:"notes"`
}

func (Account) String

func (a Account) String() string

type ConfigFunc added in v1.2.0

type ConfigFunc func(opts *ConfigOptions)

ConfigFunc allows modification of configurations in the Vault struct

func WithMultiFactor added in v1.2.0

func WithMultiFactor(code string) ConfigFunc

WithMultiFactor adds multi-factor auth to your vault.

type ConfigOptions added in v1.2.0

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

ConfigOptions are config options that set behaviours in Vault. Current supported configs is multi-factor auth.

type Field

type Field uint32

type SearchMethod

type SearchMethod uint32

type Vault

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

func New

func New(email, password string, opts ...ConfigFunc) (*Vault, error)

New logs into LastPass and returns a new Vault

func (*Vault) CreateAccount

func (lp *Vault) CreateAccount(account *Account) (*Account, error)

CreateAccount sync LastPass vault with the account info given. The return value is the struct with an added Account ID

func (*Vault) DeleteAccount

func (lp *Vault) DeleteAccount(account *Account) error

DeleteAccount removes an account from the LastPass vault by the Account ID

func (*Vault) DeleteAccountById

func (lp *Vault) DeleteAccountById(id string) error

DeleteAccountById removes an account from LastPass by the Account ID

func (Vault) Email

func (lp Vault) Email() string

Email returns the email associated with the vault

func (Vault) GetAccount

func (lp Vault) GetAccount(id string) (*Account, error)

GetAccount gets LastPass account by unique ID If not found, returns ErrAccountNotFound error

func (Vault) GetAccounts

func (lp Vault) GetAccounts() ([]*Account, error)

GetAccounts returns all accounts in the LastPass vault

func (Vault) Search

func (lp Vault) Search(value string, field Field, method SearchMethod) ([]*Account, error)

Search looks for LastPass accounts matching given args.

func (*Vault) UpdateAccount

func (lp *Vault) UpdateAccount(account *Account) (*Account, error)

UpdateAccount syncs the LastPass vault all of the fields in the account variable.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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