secrets

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(path string, identities []age.Identity) ([]byte, error)

Decrypt reads an age encrypted file and returns its plaintext.

func DecryptSops

func DecryptSops(data []byte, identities []age.Identity) ([]byte, error)

DecryptSops decrypts a sops encrypted YAML file into memory and returns the plaintext YAML.

The data key is recovered with the given age identities first, which are the ones workstation.identities names, and then with whatever sops itself finds: SOPS_AGE_KEY_FILE and its other variables, a PGP agent, or the credentials of a cloud key management service. The integrity of the whole file is verified before anything is returned.

func DecryptString

func DecryptString(path string, identities []age.Identity) (string, error)

DecryptString decrypts a file whose content is one line, such as a password, and returns it without the trailing newline.

func Identities

func Identities(paths []string) ([]age.Identity, error)

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.

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

func InspectSops(data []byte) (SopsInfo, error)

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) Summary

func (i SopsInfo) Summary() string

Summary counts the master keys per type, for example "2 age, 1 pgp".

type SopsKey

type SopsKey struct {
	Type string
	ID   string
}

SopsKey is one master key of a sops encrypted document.

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.

Jump to

Keyboard shortcuts

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