kfdb

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 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

View Source
var ErrNoSettings = errors.New("settings key not found")

ErrNoSettings is reported by UnmarshalSettings if the requested settings key is not defined on the database.

Functions

This section is empty.

Types

type DB

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

	// Settings is an opaque collection of tool-specific settings.  Each tool
	// should use its own unique key in this map. The format of the value is the
	// responsibility of the tool that defines it.
	Settings map[string]json.RawMessage `json:"settings,omitempty"`

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

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

func (*DB) MarshalSettings

func (db *DB) MarshalSettings(key string, v any) error

MarshalSettings marshals the specified value into the settings map under key, replacing any existing value for that key.

func (*DB) UnmarshalSettings

func (db *DB) UnmarshalSettings(key string, v any) error

UnmarshalSettings unmarshals the settings corresponding to key into v. If no settings for that key are available, it reports ErrNoSettings and does not modify v.

type Defaults

type Defaults struct {
	// Username, if set, is used as the default username for records that do not
	// provide one.
	Username string `json:"username,omitempty"`

	// Addr, if set, is used as the default e-mail address for records that do
	// not provide one.
	Addr string `json:"addr,omitempty"`

	// Hashpass, if set, contains defaults for the hashpass generator.
	Hashpass *Hashpass `json:"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"`

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

	// Value is the display content of the detail.
	Value string `json:"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"`

	// 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"`

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

	// Punct, if non-nil, specifies whether punctuation should be included in
	// the generated password.
	Punct *bool `json:"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"`

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

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

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

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

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

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

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

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

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

	// OTP, if non-nil, is used to generate one-time 2FA codes.
	OTP *otpauth.URL `json:"otp,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"`
}

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