Documentation ¶
Overview ¶
Package config handles keyfish configuration settings. Configurations are typically stored as JSON on disk.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilePath ¶ added in v0.0.35
func FilePath() string
FilePath returns the effective configuration file path. If KEYFISH_CONFIG is defined in the environment, that is used; otherwise the compiled-in default is used.
func SiteCandidates ¶ added in v0.0.40
SiteCandidates returns a slice of candidate site names from base. If base is structured like a host name, the candidates are the suffixes of the hostname having length at least 2. For example, given "x.y.z" the candidates are "x.y.z" and "x.y". A salt prefix (salt@x.y) is preserved on each candidate, so "s@x.y.z" yields "s@x.y.z" and "s@y.z" as candidates.
If base does not look like a hostname, the slice contains it alone.
Types ¶
type Config ¶
type Config struct { // A map from site names to site configurations. Sites map[string]Site `json:"sites,omitempty"` // A default site, overrides empty fields of a named config. Default Site `json:"default,omitempty"` // Default values for flags. Flags struct { Copy bool `json:"copy,omitempty"` OTP bool `json:"otp,omitempty"` Strict bool `json:"strict,omitempty"` Verbose bool `json:"verbose,omitempty"` } `json:"flags,omitempty"` }
A Config represents the contents of a keyfish config file.
func (*Config) Load ¶
Load loads the contents of the specified path into c. If path does not exist, the reported error satisfies os.IsNotExist and c is unmodified.
func (*Config) Site ¶
Site returns a site configuration for the given name, which has the form host.name or salt@host.name, and reports whether the config arose from a matching entry in the config. If a matching entry was found, the corresponding Site is returned; otherwise a default Site is built using the name to derive the host (and possibly the salt).
type OTPKey ¶ added in v0.0.33
type OTPKey []byte
OTPKey is the JSON encoding of an OTP secret.
func (OTPKey) MarshalJSON ¶ added in v0.0.33
MarshalJSON encodes an OTPKey to a base32 string.
func (*OTPKey) UnmarshalJSON ¶ added in v0.0.33
UnmarshalJSON decodes an OTPKey from a base32 string.
type Site ¶
type Site struct { // The hostname that identifies this site (required). // This can be any non-empty string, but conventionally is the domain name // of the site, e.g. "dartmouth.edu". Host string `json:"host"` // The hash key used to generate passwords for this site. If empty, the // hostname is used. Key string `json:"key,omitempty"` // If set, this defines the alphabet used for key generation on this site. // This overrides the Punct setting. The entries in the slice define which // components to include: // // "upper" : uppercase letters (A..Z) // "lower" : lowercase letters (a..z) // "letter" : upper + lower // "digit" : decimal digits (0..9) // "nopunct" : upper + lower + digit // "punct" : punctuation (the built-in set) // "all" : upper + lower + digit + punct // "chars:..." : the literal characters ... (order matters) // // Order is significant: For example ["digit", "chars:x"] means // "0123456789x"; whereas ["chars:x", "digit"] means "x0123456789". Alphabet []string `json:"alphabet,omitempty"` // If set, this defines the exact layout of the password. // See the Format method of hashpass.Context for details. Format string `json:"format,omitempty"` // If set, generate passwords with this many characters. // If zero, uses the default. Length int `json:"length,omitempty"` // If true, include punctuation in the password alphabet. This is ignored // if Alphabet or Format is set. Punct *bool `json:"punct,omitempty"` // Use this string as a salt for password generation. This can be used to // rotate passwords. Salt string `json:"salt,omitempty"` // The login name to use for this site. Login string `json:"login,omitempty"` // The e-mail address associated with this login. EMail string `json:"email,omitempty"` // OTP configurations for this site. The map key is the salt value for which // each configuration applies. Use "" as the key for an unsalted host. OTP map[string]*OTP `json:"otp,omitempty"` // Alternative hostnames that should be considered aliases for this site. // This is useful for sites that use a different domain for authentication. // Aliases are only examined if there is no primary host match. Aliases []string `json:"aliases,omitempty"` // User-defined password hints, security questions, and other metadata that // do not affect the password but the user may need to log in. Hints map[string]interface{} `json:"hints,omitempty"` }
A Site represents the non-secret configuration for a single site.