vault

package
v0.0.0-...-324c015 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2016 License: Apache-2.0 Imports: 11 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")
)

Functions

This section is empty.

Types

type Credential

type Credential struct {
	Username string
	Password string
}

Credential defines a Username and Password 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) Edit

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

Edit replaces the credential at location with the provided `credential`.

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) 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