Documentation
¶
Overview ¶
Package secrets keeps Blitz's secrets (API keys) out of its settings files: in the macOS Keychain, in the Secret Service on Linux (GNOME Keyring, KWallet), or, where neither is available, in an owner-only file beside the settings. A settings file refers to a stored secret as "keychain:<name>" (Ref); config resolves the reference when it loads.
Index ¶
- Constants
- Variables
- func Expand(text string, lookup func(scope, key string) (string, bool)) (string, []string)
- func HasPlaceholders(text string) bool
- func ParseRef(v string) (string, bool)
- func Ref(name string) string
- func SetDefault(s Store)
- func URN(scope, key string) string
- func ValidKey(key string) bool
- type Entry
- type FileStore
- type Memory
- type Store
- type Vault
Constants ¶
const ( AnyScope = "" OnlyGlobal = "global" OnlyWorkspace = "workspace" )
The scopes a placeholder can name: none (the workspace's, else the global one), only the global one, or only the workspace's.
const GlobalScope = "global"
GlobalScope is the scope of secrets every workspace sees.
const RefPrefix = "keychain:"
RefPrefix marks a settings value that names a stored secret.
const Service = "dev.blitz"
Service is the name secrets are stored under (the keychain item's service, the Secret Service attribute).
Variables ¶
var ErrNotFound = errors.New("no such secret")
ErrNotFound means no secret is stored under the name.
Functions ¶
func Expand ¶ added in v0.7.1
Expand puts each placeholder in text's place with its value, as lookup finds it for the scope the placeholder names (AnyScope, OnlyGlobal or OnlyWorkspace), and returns the values used (for the redactor). One lookup doesn't find is left as written.
func HasPlaceholders ¶ added in v0.7.1
HasPlaceholders reports whether text names a secret.
func SetDefault ¶
func SetDefault(s Store)
SetDefault replaces the store Default returns (tests, and the service once it knows its settings directory).
Types ¶
type FileStore ¶
type FileStore struct {
Path string
// contains filtered or unexported fields
}
FileStore keeps secrets in a TOML file.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory keeps secrets in memory, for tests.
type Store ¶
type Store interface {
// Kind says where secrets go, for people ("macOS Keychain").
Kind() string
Get(name string) (string, error)
Set(name, value string) error
Delete(name string) error
}
Store keeps secrets by name.
type Vault ¶ added in v0.7.1
Vault keeps the user's secrets in Store, their names in the index file Index.
func (Vault) Delete ¶ added in v0.7.1
Delete removes scope's secret key (a missing one isn't an error).
func (Vault) Lookup ¶ added in v0.7.1
Lookup is the secret key as a workspace in scope sees it: its own, else the global one.