Documentation
¶
Overview ¶
Package secrets decrypts the age encrypted files a site keeps beside its configuration.
Plaintext is returned in memory and streamed to wherever it is needed. It is never written to the workstation's disk, which is what the exec wrappers of the shell toolkit were careful about and what this package keeps.
Index ¶
- func Decrypt(path string, identities []age.Identity) ([]byte, error)
- func DecryptSops(data []byte, keys SopsKeys, sections []string) (values map[string]map[string]string, err error)
- func DecryptString(path string, identities []age.Identity) (string, error)
- func DefaultSopsKeyTypes() []string
- func Identities(paths []string) ([]age.Identity, error)
- func SopsValueType(s string) (string, bool)
- type SopsInfo
- type SopsKey
- type SopsKeys
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptSops ¶
func DecryptSops(data []byte, keys SopsKeys, sections []string) (values map[string]map[string]string, err error)
DecryptSops decrypts a sops encrypted YAML file into memory and returns the values of the given top level mappings, by key.
A file encrypted to a kind of master key keys.Types does not trust is refused before any key is tried. The data key is recovered with the age identities of keys.Identities first, which are the ones workstation.identities names, and then, with keys.Discover, with whatever sops itself finds, age and PGP keys before any service. The integrity of the whole file is verified before anything is returned.
The values are read from the decrypted tree as sops holds it, never written out and parsed again, and no error says anything of them.
func DecryptString ¶
DecryptString decrypts a file whose content is one line, such as a password, and returns it without the trailing newline.
func DefaultSopsKeyTypes ¶ added in v0.3.0
func DefaultSopsKeyTypes() []string
DefaultSopsKeyTypes are the kinds of master key trusted when the workstation names none: age, which needs nothing but a local identity.
func Identities ¶
Identities loads the age identities used to decrypt.
A file may hold age identities or an OpenSSH private key; both are accepted, because a site usually already has ssh keys and no reason to issue a second kind.
func SopsValueType ¶ added in v0.3.0
SopsValueType returns the type sops recorded for an encrypted value, and whether the value is one sops encrypted at all.
sops parses the plaintext as this type after decrypting it, but the type is outside what the encryption authenticates: anyone who can write the file can change it, and the parser's error then quotes the plaintext. Only "str" is read.
Types ¶
type SopsInfo ¶
type SopsInfo struct {
// Keys are the master keys the data key is encrypted to, as sops names
// their type ("age", "pgp", "kms", "gcp_kms", "azure_kv", "hc_vault")
// and the key itself, for example an age recipient or a key ARN.
Keys []SopsKey
// Groups is the number of key groups, Threshold the number of them
// needed to recover the data key when there are several.
Groups int
Threshold int
// LastModified is when sops last wrote the file.
LastModified time.Time
// EncryptedRegex is the rule that chose which values were encrypted.
EncryptedRegex string
}
SopsInfo describes a sops encrypted document, read without decrypting it.
func InspectSops ¶
InspectSops reads the sops metadata of a YAML file without decrypting anything, so that a damaged or hand edited file is reported when the configuration loads rather than when a node is half way through a reinstall.
func (SopsInfo) CheckKeyTypes ¶ added in v0.3.0
CheckKeyTypes refuses a document encrypted to a kind of master key that is not trusted here. The metadata that names the keys is not covered by the message authentication code, so anyone who can write the file can add a Vault or a key management service there, and sops would send this machine's credentials to it.
type SopsKeys ¶ added in v0.3.0
type SopsKeys struct {
// Identities are the age identities of workstation.identities. They
// are tried first.
Identities []age.Identity
// Discover lets sops look for keys itself as well: SOPS_AGE_KEY_FILE
// and its other variables, ~/.config/sops/age/keys.txt, a PGP agent,
// the credentials of a cloud key management service or Vault. That can
// run a program or ask for a passphrase, so it is for a terminal only.
Discover bool
// Types are the kinds of master key trusted, DefaultSopsKeyTypes when
// empty. A file encrypted to any other kind is refused.
Types []string
}
SopsKeys says which keys may open a sops file.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sopstest writes sops encrypted files for tests, the way "sops --encrypt --encrypted-regex '^(data|binaryData)$'" writes them, so that no test depends on a sops binary or on a private key kept in the repository.
|
Package sopstest writes sops encrypted files for tests, the way "sops --encrypt --encrypted-regex '^(data|binaryData)$'" writes them, so that no test depends on a sops binary or on a private key kept in the repository. |