vault

package
v0.0.0-...-4dc014b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSuchCredential is returned from a Get call if the requested
	// credential does not exist
	ErrNoSuchCredential = errors.New("credential at specified location does not exist in vault")

	// ErrCouldNotDecrypt is returned if secretbox decryption fails.
	ErrCouldNotDecrypt = errors.New("provided decryption key is incorrect or the provided vault is corrupt")

	// ErrCredentialExists is returned from Add if a credential already exists
	// at the provided location.
	ErrCredentialExists = errors.New("credential at specified location already exists")

	// ErrMetaExists is returned from AddMeta if a meta tag already exists.
	ErrMetaExists = errors.New("meta tag already exists")

	// ErrMetaDoesNotExist is returned from Editmeta if a meta tag does not
	// exist.
	ErrMetaDoesNotExist = errors.New("meta tag does not exist")
)

Functions

This section is empty.

Types

type Credential

type Credential struct {
	Username string
	Password string

	Meta map[string]string
}

Credential defines a Username and Password, and a map of Metadata to store inside the vault.

type Vault

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

Vault is a secure password vault. It can be created by calling New() with a passphrase. Passwords, usernames, and locations are encrypted using nacl/secretbox.

func New

func New(passphrase string) (*Vault, error)

New creates a new, empty, vault using the passphrase provided to `passphrase`.

func Open

func Open(filename string, passphrase string) (*Vault, error)

Open reads a vault from the location provided to `filename` and decrypts it using `passphrase`. If decryption succeeds, new nonce is chosen and the vault is re-encrypted, ensuring nonces are unique and not reused across sessions.

func (*Vault) Add

func (v *Vault) Add(location string, credential Credential) error

Add adds the credential provided to `credential` at the location provided by `location` to the vault.

func (*Vault) AddMeta

func (v *Vault) AddMeta(location string, name string, value string) error

AddMeta adds a meta tag to the credential in the vault at `location`. `name` is used for the name of the meta tag and `value` is used as its value.

func (*Vault) ChangePassphrase

func (v *Vault) ChangePassphrase(newpassphrase string) error

ChangePassphrase re-encrypts the entire vault with a new master key derived from the provided `newpassphrase`.

func (*Vault) Delete

func (v *Vault) Delete(location string) error

Delete removes the credential at `location`.

func (*Vault) DeleteMeta

func (v *Vault) DeleteMeta(location string, metaname string) error

DeleteMeta removes a meta tag from the credential at `location`.

func (*Vault) Edit

func (v *Vault) Edit(location string, credential Credential) error

Edit replaces the credential at location with the provided `credential`. The metadata from the old credential is preserved.

func (*Vault) EditMeta

func (v *Vault) EditMeta(location string, name string, newvalue string) error

EditMeta changes a meta tag at a given location and meta tag name to `newvalue`.

func (*Vault) Find

func (v *Vault) Find(searchtext string) (string, *Credential, error)

Find searches the vault for locations containing the `searchtext` and returns the matching credential name and credential if it is found. Otherwise, an error `ErrNoSuchCredential` will be returned.

func (*Vault) FindMeta

func (v *Vault) FindMeta(location string, searchtext string) (string, string, error)

FindMeta search the credential at location `location` for a meta value containing `serachtext` and returns the meta name and value if it is found. Otherwise, an error `ErrMetaDoesNotExist` will be returned.

func (*Vault) Generate

func (v *Vault) Generate(location string, username string) error

Generate generates a new strong mnemonic passphrase and Add()s it to the vault.

func (*Vault) Get

func (v *Vault) Get(location string) (*Credential, error)

Get retrieves a Credential at the provided `location`.

func (*Vault) LoadCSV

func (v *Vault) LoadCSV(c io.Reader, locationField, usernameField, passwordField string) (int, error)

LoadCSV loads password data from a CSV file. The text provided by locationField is used as the key for Location data, usernameField and passwordField are used as the key for the Username and Password data.

func (*Vault) Locations

func (v *Vault) Locations() ([]string, error)

Locations retrieves the locations in the vault and returns them as a slice of strings.

func (*Vault) Save

func (v *Vault) Save(filename string) error

Save safely (atomically) persists the vault to disk at the filename provided to `filename`.

Jump to

Keyboard shortcuts

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