kfdb

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package kfdb implements a database of sensitive values maintained by keyfish.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// Defaults are default values for certain record fields.
	Defaults *Defaults `json:"defaults,omitempty" yaml:"defaults,omitempty"`

	// Records are the data records contained in the database.
	Records []*Record `json:"records,omitempty" yaml:"records,omitempty"`
}

A DB is a database of sensitive data managed by keyfish.

type Defaults

type Defaults struct {
	// Hashpass, if set, contains defaults for the hashpass generator.
	Hashpass *Hashpass `json:"hashpass,omitempty" yaml:"hashpass,omitempty"`
}

Defaults are default values applied to records that do not define their own values for certain fields.

type Detail

type Detail struct {
	// Label is a human-readable label for the detail.
	Label string `json:"label" yaml:"label"`

	// Hidden, if true, indicates the value is sensitive and should not be
	// displayed plainly unless the user requests it.
	Hidden bool `json:"hidden,omitempty" yaml:"hidden,omitempty"`

	// Value is the display content of the detail.
	Value string `json:"value" yaml:"value"`
}

Detail is a labelled data annotation for a record.

type Hashpass

type Hashpass struct {
	// SecretKey, if set, is used as the hashpass generator key.
	SecretKey string `json:"secretKey,omitempty" yaml:"secret-key,omitempty"`

	// Seed is the seed used for password generation. If empty, the first
	// element of the Hosts for the record is used.
	Seed string `json:"seed,omitempty" yaml:"seed,omitempty"`

	// Length specifies the length of the generated password in characters.
	// If zero, the default length is used.
	Length int `json:"length,omitempty" yaml:"length,omitempty"`

	// Punct, if non-nil, specifies whether punctuation should be included in
	// the generated password.
	Punct *bool `json:"punct,omitempty" yaml:"punct,omitempty"`
}

Hashpass contains settings for a HKDF password generator.

type Record

type Record struct {
	// Label is a short identifier for this record.
	Label string `json:"label,omitempty" yaml:"label,omitempty"`

	// Title is a human-readable title for this record.
	Title string `json:"title,omitempty" yaml:"title,omitempty"`

	// Archived, if true, indicates the record is archived and should not be
	// shown in default listings and search results.
	Archived bool `json:"archived,omitempty" yaml:"archived,omitempty"`

	// Username is the user name or login associated with this record.
	Username string `json:"username,omitempty" yaml:"username,omitempty"`

	// Hosts are optional hostnames associated with this record.
	Hosts Strings `json:"hosts,omitempty" yaml:"hosts,flow,omitempty"`

	// Addrs are e-mail addresses associated with this record.
	Addrs Strings `json:"addrs,omitempty" yaml:"addrs,flow,omitempty"`

	// Tags are optional query tags associated with this record.
	Tags []string `json:"tags,omitempty" yaml:"tags,flow,omitempty"`

	// Notes are optional human-readable notes.
	Notes string `json:"notes,omitempty" yaml:"notes,omitempty"`

	// Hashpass, if non-nil, is a configuration for a hashed password.
	Hashpass *Hashpass `json:"hashpass,omitempty" yaml:"hashpass,omitempty"`

	// Password, if non-empty, is a generated password.
	Password string `json:"password,omitempty" yaml:"password,omitempty"`

	// OTP, if non-nil, is used to generate one-time 2FA codes.
	OTP *otpauth.URL `json:"otp,omitempty" yaml:"otp,omitempty"`

	// Details are optional labelled data annotations.
	Details []*Detail `json:"details,omitempty" yaml:"details,omitempty"`
}

A Record records an item of interest such as a login account.

type Store

type Store = kfstore.Store[DB]

Store is an alias for kfstore.Store to avoid the need to import the kfstore package directly.

func New

func New(passphrase string, init *DB) (*Store, error)

New creates a new DB store using the given passphrase to generate a store access key. If init != nil, it is used as the initial database.

func Open

func Open(r io.Reader, passphrase string) (*Store, error)

Open reads a DB store from r using the given passphrase to generate a store access key.

type Strings

type Strings = array[string]

Strings is a convenience alias for an array of strings that decodes from JSON as either a single string or an array of multiple strings.

Jump to

Keyboard shortcuts

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