Documentation
¶
Overview ¶
Package secret is beekeeper secret: the credential operations beekeeper runs in its own process so that no agent reads a value. sops and op run here, the values they answer stay in memory for the one operation, and what an operation returns is key names, lengths, equality and keyed fingerprints, never a value. Nothing is written in plaintext: a SOPS file is written encrypted, from sops' own output.
Index ¶
- Constants
- Variables
- func AgeInstallationItem(installation string) string
- func AgeItemRef(vault, recipient string) string
- func AgeItemTitle(recipient string) string
- func ApplySecret(ctx context.Context, kubeconfig []byte, t KubeTarget, value []byte) error
- func Askpass(sock, prompt string, w io.Writer) error
- func AskpassMain(args []string, stdout, stderr io.Writer) int
- func BrokerProcess() (int, string, error)
- func Charsets() []string
- func ClearClipboard(ctx context.Context, run Runner) error
- func Clipboard(ctx context.Context, run Runner) (string, error)
- func Consumer(argv []string) error
- func ConsumerContext(argv []string) string
- func Exec(ctx context.Context, dir string, env []string, stdin io.Reader, name string, ...) ([]byte, error)
- func Expired(stderr string) bool
- func Generate(n int, charset string) (string, error)
- func GitConsumer(argv []string) error
- func ImportRecipient(path string) (string, error)
- func IsSSH(s string) bool
- func NeedsStore(args []string) bool
- func NeedsVault(args []string) bool
- func NewestFile(dir, pattern string) (string, error)
- func ParseItem(s string) (vault, item string, err error)
- func ParseSignin(out []byte) (string, string, error)
- func Peer(c net.Conn) error
- func ProducerEnv(environ, drop []string) []string
- func Protect() error
- func ReadSecret(ctx context.Context, kubeconfig []byte, t KubeTarget) ([]byte, error)
- func ReadValueFile(path string) (string, error)
- func RestartBroker(ctx context.Context) error
- func ServeVault(ctx context.Context, path string, k *Keeper, store Storer, ...) error
- func Shred(path string) error
- func SocketPath() (string, error)
- func StatePath() (string, error)
- func Uptime() (time.Duration, error)
- func UseProducersIn(dir string) (restore func())
- func VaultRef(vault string) string
- func WaitsPath() (string, error)
- func WriteSecretKey(ctx context.Context, c client.Client, t KubeTarget, value []byte) error
- func WriteState(path string, st VaultState) error
- func WriteWaits(path string, ws []VaultWait) error
- type AgeIdentity
- type CaptureOptions
- type CaptureResult
- type Carrier
- type Credential
- type DockerConfig
- type Encoding
- type EnvKey
- type Field
- type FieldInfo
- type Handover
- type Item
- type ItemField
- type ItemStorer
- type ItemsOptions
- type Keeper
- func (k *Keeper) Drop(reason string, now time.Time)
- func (k *Keeper) Env() string
- func (k *Keeper) Lock()
- func (k *Keeper) PrepareHandover() error
- func (k *Keeper) RestoreHandover() (result error)
- func (k *Keeper) RevokeHandover() error
- func (k *Keeper) State() VaultState
- func (k *Keeper) Unlock(name, token string, now time.Time) error
- func (k *Keeper) Wait(ctx context.Context) error
- type Key
- type KubeTarget
- type NewSecret
- type Ops
- func (o *Ops) AgeNeedsIdentity(dir string, args []string) bool
- func (o *Ops) AgeNeedsVault(dir string, args []string) bool
- func (o *Ops) Capture(ctx context.Context, dst Ref, opt CaptureOptions) (CaptureResult, error)
- func (o *Ops) Compare(ctx context.Context, a, b Ref) ([]Verdict, error)
- func (o *Ops) CopyDocker(ctx context.Context, src Ref, file string, d DockerConfig, nw *NewSecret) (int, error)
- func (o *Ops) CopyFile(ctx context.Context, src Ref, dst, name, namespace string) ([]Key, error)
- func (o *Ops) CopyToConsumer(ctx context.Context, src Ref, argv []string, in Stdin) (int, string, error)
- func (o *Ops) CopyToGit(ctx context.Context, src Ref, argv []string, user string) (int, string, error)
- func (o *Ops) CopyToRemote(ctx context.Context, src Ref, f RemoteFile) (RemoteResult, error)
- func (o *Ops) CopyToSecret(ctx context.Context, src Ref, t KubeTarget) (int, error)
- func (o *Ops) CopyValue(ctx context.Context, src, dst Ref) (int, error)
- func (o *Ops) CopyValues(ctx context.Context, pairs []Pair, file string, nw *NewSecret) ([]Key, error)
- func (o *Ops) Fingerprints(ctx context.Context, r Ref) ([]Print, error)
- func (o *Ops) Handover(ctx context.Context, creds []Credential) (*Handover, error)
- func (o *Ops) Import(ctx context.Context, src, dst Ref) (int, error)
- func (o *Ops) ImportAge(ctx context.Context, src Ref, recipient string) (Ref, int, error)
- func (o *Ops) Items(ctx context.Context, vault string, opt ItemsOptions) ([]Item, error)
- func (o *Ops) ListVaults() []string
- func (o *Ops) ReadVaults() []string
- func (o *Ops) Recipients(ctx context.Context, path string) ([]Recipient, error)
- func (o *Ops) Reveal(ctx context.Context, file string, paths []string) ([]Field, error)
- func (o *Ops) RevealTo(ctx context.Context, file, path string, dst Ref, write bool) (RevealResult, error)
- func (o *Ops) RotateGenerated(ctx context.Context, ref Ref, files []string, ix *guard.Index, length int, ...) (Rotation, error)
- func (o *Ops) RotateIssued(ctx context.Context, ref Ref, files []string, ix *guard.Index) (Rotation, error)
- func (o *Ops) RotatePlatform(ctx context.Context, r PlatformRef, reason string, dryRun bool) (string, error)
- func (o *Ops) SecretFingerprint(ctx context.Context, t KubeTarget) (Print, error)
- func (o *Ops) SecretKeys(ctx context.Context, file string, opt SecretKeysOptions) ([]CaptureResult, error)
- func (o *Ops) Set(ctx context.Context, dst Ref, opt SetOptions) (SetResult, error)
- func (o *Ops) SetSOPSValue(ctx context.Context, dst Ref, v string) error
- func (o *Ops) Setup(ctx context.Context, account, tokenFile string) (Setup, error)
- func (o *Ops) StoreFields(ctx context.Context, vault, item string, fields []ItemField) ([]Stored, error)
- func (o *Ops) StoreValue(ctx context.Context, dst Ref, v string) (Stored, error)
- func (o *Ops) Unset(ctx context.Context, file string, paths []string, write bool) (UnsetResult, error)
- func (o *Ops) Use(ctx context.Context, r Ref, use func(v string) error) error
- func (o *Ops) Writable(dst Ref) error
- type Pair
- type PlatformRef
- type Print
- type Producer
- type Recipient
- type Ref
- type RemoteFile
- type RemoteResult
- type RevealResult
- type Rotation
- type Runner
- type SecretApplier
- type SecretKeysOptions
- type SecretKeysPlan
- type SecretReader
- type SetOptions
- type SetResult
- type Setup
- type SigninCause
- type Stdin
- type Store
- type StoreState
- type Stored
- type Storer
- type UnsetResult
- type VaultRequest
- type VaultState
- type VaultWait
- type Verdict
Constants ¶
const ( // FileRef starts the reference of a file on the host: an age identity // file, or one value of a plain file as a source (file://<path>#<path>). FileRef = "file://" // StoreRef starts the reference of an entry of the person's own // credential store; with no entry, the store's search finds it by the // file's recipients. StoreRef = "store://" )
The references of an age identity besides a vault field.
const ( Equal = "equal" Different = "different" OnlyA = "only in a" OnlyB = "only in b" )
The states compare answers per key.
const ( VaultUnlock = "unlock" VaultLock = "lock" VaultStatus = "status" VaultPrepare = "prepare-handover" VaultRevoke = "revoke-handover" VaultStore = "store" VaultStoreItem = "store-item" )
The socket's operations.
const BrokerUnit = "beekeeper-sandbox.service"
BrokerUnit is the systemd user unit whose main process is the broker.
const CmdRef = "cmd://"
CmdRef starts the reference of a value a producer command generates, cmd://<command>#<path>: the command one of Producers, run in beekeeper's process, the path a dotted key of its JSON or YAML stdout (none: the whole stdout without its line end).
const FieldManager = "beekeeper-secret"
FieldManager is the field manager a copied key is written under.
const GitUser = "oauth2"
GitUser is the user name the askpass helper answers by default: GitLab takes any for a token, GitHub too.
const K8sRef = "k8s://"
K8sRef starts a reference to a key of a Kubernetes Secret as a source: k8s://<context>/<namespace>/<name>/<key>, and after # the dotted path of one value inside the YAML (or JSON) document the key holds.
const Locked = "vault locked: waiting for the broker's sign-in"
Locked is the message of a call that waits on the person's unlock.
const MaxItemBytes = 4 * MaxStoreBytes
MaxItemBytes bounds the values of one store into an item together: a GitHub App's credentials, its private key included, fit many times over.
const MaxStoreBytes = 32 << 10
MaxStoreBytes bounds a stored value: a private key or a certificate chain fits, a file that is no credential does not.
const None = "none"
None opens the identity of a recipient beekeeper cannot decrypt for.
const PlatformPrefix = "platform://"
PlatformPrefix opens a PlatformRef.
const SSHRef = "ssh://"
SSHRef starts a remote file target: ssh://[<user>@]<host>[:<port>]/<path>.
const TemplateValue = "{{value}}"
TemplateValue is the placeholder of a --template the value replaces.
Variables ¶
var AskpassArgs = []string{"secret", "askpass"}
AskpassArgs are the arguments after the binary that make beekeeper the git askpass helper: secret askpass <socket> <prompt>.
var ErrCredentialShape = errors.New("refused")
ErrCredentialShape refuses a literal that looks like a credential.
var ErrEmptyValue = errors.New("the value is empty or blank: nothing written")
ErrEmptyValue refuses to write an empty or blank value, which a broken source answers more often than a credential holds.
var ErrLocked = errors.New("vault locked")
ErrLocked is a vault the person did not unlock in time.
var ErrNoAgeIdentity = errors.New("no age identity")
ErrNoAgeIdentity marks a SOPS file whose age recipients no identity beekeeper can reach decrypts for.
var ErrNoHandover = errors.New("no usable vault handover")
ErrNoHandover is an expected empty, revoked or expired handover. The broker starts locked and continues serving its other operations.
var ErrSecretLike = errors.New("looks secret")
ErrSecretLike is reveal's refusal of a leaf the classifier takes for a secret.
var ErrSetUp = errors.New("already set up")
ErrSetUp is a token file that already holds a token: setup creates one service account once, a second would orphan the first.
var ErrVault = errors.New("the shared vault cannot be read")
ErrVault marks a failure to read the shared vault: none configured, no token, or op answering an error or no answer in time.
var ErrWriteConflict = errors.New("SOPS write conflict: reread the destination and retry")
ErrWriteConflict means the destination changed or another writer is committing. Callers must reread the document before retrying the operation.
var Producers = []Producer{ {Words: []string{"az", "acr", "token", "credential", "generate"}, Options: map[string]bool{ "--registry": true, "-r": true, "--name": true, "-n": true, "--resource-group": true, "-g": true, "--subscription": true, "--password1": false, "--password2": false, "--expiration": true, "--expiration-in-days": true, "--output": true, "-o": true, "--query": true, "--only-show-errors": false, }}, {Words: []string{"openssl", "genpkey"}, Options: map[string]bool{"-algorithm": true, "-pkeyopt": true}}, {Words: []string{"openssl", "rand"}, Options: map[string]bool{"-hex": false, "-base64": false}, Operand: isCount}, }
Producers are the commands a cmd:// reference and secret capture may run; every other command, and every option a producer does not list, is refused: az's --debug and --verbose log the generated password on stderr, openssl's -out writes a file a session could read, its -engine, -provider and -config load code. The list is beekeeper's own, no configuration widens it.
Functions ¶
func AgeInstallationItem ¶ added in v0.114.0
AgeInstallationItem is the title of the vault item that holds the identity of installation's recipient.
func AgeItemRef ¶ added in v0.109.0
AgeItemRef is the op:// reference of recipient's identity in vault.
func AgeItemTitle ¶ added in v0.109.0
AgeItemTitle is the title of the vault item that holds recipient's identity.
func ApplySecret ¶ added in v0.81.0
ApplySecret is the SecretApplier of a real cluster: WriteSecretKey through the kubeconfig's cluster.
func Askpass ¶ added in v0.119.0
Askpass is the helper's side: it asks the socket for prompt's answer and writes it to w, for git to read. A prompt beekeeper answers nothing to fails.
func AskpassMain ¶ added in v0.119.0
AskpassMain runs the askpass helper for args after AskpassArgs, answering the exit code.
func BrokerProcess ¶ added in v0.148.0
BrokerProcess is the broker unit's main process and the binary its unit starts; an error when it does not run.
func ClearClipboard ¶ added in v0.118.0
ClearClipboard empties the Wayland clipboard (wl-copy --clear), so that a stored value does not wait there for the next paste.
func Clipboard ¶ added in v0.118.0
Clipboard reads the Wayland clipboard through wl-paste, trimmed of the whitespace a selection drags along; "" when nothing is copied.
func Consumer ¶
Consumer allows a command to take a value on stdin: one that reads a secret from stdin and stores it without printing it (gitlab-rails runner's code reading STDIN among them), or kubectl exec -i handing stdin to such a command in a pod. git takes a value through GitConsumer's askpass path instead.
func ConsumerContext ¶ added in v0.96.0
ConsumerContext is the kube context a valid kubectl exec consumer names, or "" for any other or invalid consumer.
func Exec ¶
func Exec(ctx context.Context, dir string, env []string, stdin io.Reader, name string, args ...string) ([]byte, error)
Exec is the Runner of the real tools, found on PATH or in the Go tool directories (proc.LookPath): the sandbox broker's calls run with the service manager's PATH, without the directory kind lives in.
func GitConsumer ¶ added in v0.119.0
GitConsumer allows a git operation that authenticates over HTTPS with the credential beekeeper's askpass helper answers: git [-C <dir>] clone, fetch, push or ls-remote, without an option that sets configuration or names a program to run (a credential helper or an upload-pack would get the credential's way in).
func ImportRecipient ¶ added in v0.139.0
ImportRecipient is the one age recipient path's .sops.yaml declares, the recipient whose identity an import stores. For a SOPS file it is the file's recipient (its metadata's when encrypted, else its creation rule's); for a directory the recipient of the creation rule sops applies to the files below it (the first without a path_regex or whose path_regex matches the directory), else the one recipient all its creation rules share. No rule, or several recipients, is an error naming path.
func NeedsStore ¶ added in v0.171.0
NeedsStore reports a store source before the consumer separator, including the sources of a multi-value copy. Callers must preserve the separator or pass only arguments before it.
func NeedsVault ¶ added in v0.91.0
NeedsVault reports whether a beekeeper secret call's arguments name the shared vault: an op:// reference, a flag's value included.
func NewestFile ¶ added in v0.118.0
NewestFile is the newest regular file in dir whose name matches the glob pattern, "" when none.
func ParseItem ¶ added in v0.125.0
ParseItem reads op://<vault>/<item>, an item of the shared vault.
func ParseSignin ¶ added in v0.91.0
ParseSignin reads the session op signin printed: its variable's name and the token.
func Peer ¶ added in v0.91.0
Peer checks that the other end of c is this user's broker: the main process of BrokerUnit, whose unit runs this very binary. The keeper's socket path is the person's, but a process that took the path first must not get a session. The broker is undumpable (Protect), so its /proc/<pid>/exe belongs to root and tells nothing; systemd names the process and the binary instead.
func ProducerEnv ¶ added in v0.119.0
ProducerEnv is a producer's clean environment: [producerPATH], HOME from the user database, never the caller's, and the variables of environ whose names match one of [producerVars] and none of the globs of drop, secret.env.
func Protect ¶ added in v0.91.0
func Protect() error
Protect makes this process undumpable: no other process of the user reads its memory or environment through /proc or ptrace, and it leaves no core dump with the session in it.
func ReadSecret ¶ added in v0.111.0
ReadSecret is the SecretReader of a real cluster.
func ReadValueFile ¶ added in v0.118.0
ReadValueFile reads a file holding one value, of at most MaxStoreBytes.
func RestartBroker ¶ added in v0.148.0
RestartBroker restarts the broker unit, onto the binary its unit starts: the vault session it keeps goes with the old process.
func ServeVault ¶ added in v0.91.0
func ServeVault(ctx context.Context, path string, k *Keeper, store Storer, storeItem ItemStorer) error
ServeVault answers the keeper's socket at path until ctx ends; store writes what a store request hands over and storeItem what a store-item does (nil refuses one).
func Shred ¶ added in v0.118.0
Shred overwrites path with random bytes and removes it: a downloaded key file leaves no plaintext behind once the vault holds it.
func SocketPath ¶ added in v0.91.0
SocketPath is the keeper's socket under the runtime directory.
func StatePath ¶ added in v0.93.0
StatePath is the broker's vault state, next to the keeper's socket: whether it holds a session, since and until when, never the session. The watch reads it.
func UseProducersIn ¶ added in v0.168.3
func UseProducersIn(dir string) (restore func())
UseProducersIn makes the producers resolve in dir alone, trusted whoever owns it, until restore runs: the place a test's fake az or openssl stands in. Nothing but a test calls it.
func WaitsPath ¶ added in v0.91.0
WaitsPath is the broker's list of waiting calls, next to the keeper's socket: the watch and beekeeper status read it, no sandboxed session writes it.
func WriteSecretKey ¶ added in v0.108.3
WriteSecretKey writes value into the one key of the Secret t names: a merge patch of that key alone, so the Secret's other keys, labels and annotations stay whoever wrote them; a Secret absent is created with the key. A server-side apply would own the whole data of the Secret under FieldManager and drop the keys an earlier copy wrote.
func WriteState ¶ added in v0.93.0
func WriteState(path string, st VaultState) error
WriteState replaces the broker's vault state, through a rename.
func WriteWaits ¶ added in v0.91.0
WriteWaits replaces the list of waiting calls, through a rename.
Types ¶
type AgeIdentity ¶ added in v0.92.0
type AgeIdentity struct {
// Recipient is the age recipient (age1…) the identity decrypts for.
Recipient string
// Path matches the file's absolute path; nil matches by recipient only.
Path *regexp.Regexp
// Ref is the op:// field, the file:// identity file or the store://
// entry that holds the identity (AGE-SECRET-KEY-1…, an identity file's
// comments allowed).
Ref string
// contains filtered or unexported fields
}
AgeIdentity is where beekeeper finds the age identity of a SOPS file none of sops' own sources holds: a field of the shared vault, an identity file on the host or an entry of the person's own credential store, read in beekeeper's process and given to the one sops call's environment alone.
type CaptureOptions ¶ added in v0.119.0
type CaptureOptions struct {
// Producer is the command that prints the value, one of [Producers],
// run in this process.
Producer []string
// Env is the producer's environment ([ProducerEnv]).
Env []string
// JQ is a jq filter that picks the value out of the producer's JSON
// output, one string; empty takes the whole output, its line end
// trimmed.
JQ string
// Vault is the shared vault's field that holds the value first.
Vault Ref
// Docker writes the value as the .dockerconfigjson of a
// kubernetes.io/dockerconfigjson Secret instead of at a path.
Docker *DockerConfig
// New is the Secret a file absent so far starts as.
New *NewSecret
}
CaptureOptions are the producer whose stdout a capture takes the value from and where the value goes besides the SOPS path.
type CaptureResult ¶ added in v0.119.0
type CaptureResult struct {
Key string `json:"key"`
Bytes int `json:"bytes"`
Fingerprint string `json:"fingerprint"`
}
CaptureResult is what a capture answers: where the value went, its length as written and its keyed fingerprint.
type Carrier ¶ added in v0.73.0
Carrier is a SOPS path that carried a rotated value: the value itself, or its base64 form (a Kubernetes Secret's data).
type Credential ¶ added in v0.109.0
Credential is a value a process beekeeper starts gets in its environment: the variable Name, from Ref.
type DockerConfig ¶ added in v0.119.0
DockerConfig is the kubernetes.io/dockerconfigjson shape a captured registry password takes: the registry it pulls from and the user it authenticates.
type Encoding ¶ added in v0.111.0
type Encoding struct {
// Base64 encodes the value in standard base64.
Base64 bool `json:"base64,omitempty"`
// User, when set, encodes base64("<user>:<value>"), an HTTP Basic
// credential.
User string `json:"user,omitempty"`
}
Encoding transforms a value before it is written, inside beekeeper's process: a consumer that injects a value verbatim (a gateway's "Authorization: Basic <value>") needs the encoded form, which no caller could otherwise make without reading the value. The zero Encoding writes the value as it is.
func ParseEncoding ¶ added in v0.111.0
ParseEncoding reads base64 or basic:<user>; "" is the value as it is.
type EnvKey ¶ added in v0.148.0
type EnvKey struct {
Field string `json:"field"`
Key string `json:"key"`
Length int `json:"length"`
}
EnvKey is one KEY=VALUE line of an env-style field: the field, the key and the length of its value in bytes, never the value.
type Field ¶ added in v0.114.0
Field is a revealed leaf of a SOPS file: its dotted path and its value, configuration the classifier found no secret in.
type FieldInfo ¶ added in v0.147.0
type FieldInfo struct {
Label string `json:"label"`
Section string `json:"section,omitempty"`
Type string `json:"type,omitempty"`
Purpose string `json:"purpose,omitempty"`
Length int `json:"length"`
}
FieldInfo is one field of an item: its label, the section it sits in, its type and purpose, and the length of its value in bytes.
type Handover ¶ added in v0.109.0
type Handover struct {
// contains filtered or unexported fields
}
Handover holds the values of a process's credentials, read from their references, until they are written into its environment: NAME=value lines for a process that reads its environment that way before it runs, an omp agent's shell from its inbox. The values live here and go to the writer alone.
type Item ¶ added in v0.147.0
type Item struct {
Title string `json:"title"`
ID string `json:"id"`
Category string `json:"category,omitempty"`
Tags []string `json:"tags,omitempty"`
Updated string `json:"updated,omitempty"`
Fields []FieldInfo `json:"fields,omitempty"`
EnvKeys []EnvKey `json:"envKeys,omitempty"`
}
Item is what items answers of one vault item: its metadata and, when asked, its fields' names, types and lengths, never a value.
type ItemField ¶ added in v0.125.0
type ItemField struct {
Label string `json:"label"`
Value string `json:"value"`
Plain bool `json:"plain,omitempty"`
}
ItemField is one field of a store into a vault item: its label, its value and whether it is configuration, a plain string, rather than a secret, which is concealed.
type ItemStorer ¶ added in v0.125.0
ItemStorer writes fields into the vault item (op://<vault>/<item>) with the session env, in one op call, and answers what it wrote per field.
type ItemsOptions ¶ added in v0.147.0
type ItemsOptions struct {
// Match keeps the items whose title, category or a tag contains it,
// case-insensitively; empty keeps every item.
Match string
// Fields reads each kept item for its fields' names and lengths.
Fields bool
// EnvKeys reads each kept item for the keys of its env-style fields'
// KEY=VALUE lines and their values' lengths.
EnvKeys bool
// KeyPattern keeps only env keys containing this case-insensitive substring,
// and omits items with no matching keys. Requires EnvKeys.
KeyPattern string
}
ItemsOptions narrow a listing.
type Keeper ¶ added in v0.91.0
type Keeper struct {
// contains filtered or unexported fields
}
Keeper holds the vault session in memory, for its lifetime at most.
func NewKeeper ¶ added in v0.91.0
func NewKeeper(lifetime time.Duration, changed func(VaultState)) *Keeper
NewKeeper is a locked keeper that holds a session for lifetime and tells changed (nil: no one) each new state in transition order. Callbacks may read and reenter the keeper. Transitions during a callback queue their notifications for delivery after that callback returns.
func (*Keeper) Drop ¶ added in v0.97.0
Drop forgets a session op no longer takes, and says why until the next unlock.
func (*Keeper) Env ¶ added in v0.91.0
Env is the session's environment entry for op, "" while locked.
func (*Keeper) Lock ¶ added in v0.91.0
func (k *Keeper) Lock()
Lock forgets the session: the person's lock, or one op no longer takes.
func (*Keeper) PrepareHandover ¶ added in v0.171.0
PrepareHandover gives systemd an anonymous memory descriptor. Neither the installer nor any socket reply receives the session. A later lock or unlock invalidates this snapshot, so a restart cannot resurrect a revoked session.
func (*Keeper) RestoreHandover ¶ added in v0.171.0
RestoreHandover consumes only this service's inherited descriptor, before any sign-in or child process. The original expiry is never extended.
func (*Keeper) RevokeHandover ¶ added in v0.171.0
RevokeHandover wipes shared memory before asking systemd to drop its copy of the descriptor. A failed notification cannot leave a usable snapshot.
func (*Keeper) State ¶ added in v0.93.0
func (k *Keeper) State() VaultState
State is whether the keeper holds a session, since when and until when.
type KubeTarget ¶ added in v0.81.0
type KubeTarget struct {
Context string `json:"context"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Key string `json:"key"`
}
KubeTarget is one key of a Secret: <context>/<namespace>/<name>/<key>.
func ParseKubeTarget ¶ added in v0.81.0
func ParseKubeTarget(s string) (KubeTarget, error)
ParseKubeTarget reads <context>/<namespace>/<name>/<key>.
func (KubeTarget) KindCluster ¶ added in v0.81.0
func (t KubeTarget) KindCluster() string
KindCluster is the kind cluster a kind-<cluster> context names, "" for any other context.
func (KubeTarget) String ¶ added in v0.81.0
func (t KubeTarget) String() string
String is the target as a log and an answer name it.
type Ops ¶
type Ops struct {
Run Runner
// Vault is the shared 1Password vault, the only one an op:// reference
// may name; empty refuses every op:// reference.
Vault string
// Vaults are the shared vaults besides Vault that an op:// reference
// may read from (copy, compare, fingerprint); writes go to Vault alone.
Vaults []string
// Token is the vault's service account token, which only op's own
// environment gets; empty refuses every op:// reference.
Token string
// Session reads the vault through the person's own signed-in op
// session (OP_SESSION_* in the caller's environment) instead of a
// service account: the way to a vault no service account can be
// granted, such as a person's Employee vault.
Session bool
// Env is what op's environment gets besides this process's own in
// session mode: the broker's own calls give the vault session here; a
// brokered child carries it in its environment already.
Env []string
// Fingerprint is the keyed hash fingerprint answers with.
Fingerprint func(value string) string
// Apply writes a key of a Secret; nil is [ApplySecret].
Apply SecretApplier
// Read reads a key of a Secret; nil is [ReadSecret].
Read SecretReader
// Kubeconfig are the kubeconfig files a k8s:// reference's context is
// resolved in, outside a kind lab (whose kubeconfig kind answers);
// empty refuses every such reference.
Kubeconfig []string
// Encode transforms the value a copy writes, set writes besides the
// vault, and fingerprint answers for; the zero Encoding keeps it as it is.
Encode Encoding
// Ages are the age identities of the shared vault, an identity file or
// the person's own credential store for the SOPS files sops' own
// sources hold none for.
Ages []AgeIdentity
// AgeVaults are the vaults besides Vault that age identities are read
// from: an op:// entry of Ages may name one, and the item of a SOPS
// file's installation ([AgeInstallationItem]) is looked up in Vault and
// each of them.
AgeVaults []string
// AgeCache stores only public recipient-to-item metadata; nil disables caching.
AgeCache interface {
ReadFile(string, any) (bool, error)
WriteFile(string, any) error
}
// Store is the person's own credential store for sources and age identities.
Store Store
// Index is the value scanner's index reveal checks a value against, its
// indexed secrets and token patterns; nil checks the patterns alone.
Index *guard.Index
// Installations are the installations' names, which a SOPS file's path
// under its .sops.yaml carries as a directory: a refusal names the one
// whose recipient has no identity.
Installations []string
// FileRoots are the directories a file:// reference's plain file must
// lie under; empty refuses every such reference.
FileRoots []string
// Produce lets a cmd:// reference run its producer: copy's, whose
// value is stored; every other operation refuses one.
Produce bool
// SecretEnv are the globs of the environment variables a producer
// runs without (secret.env), besides the vault's and sops' own.
SecretEnv []string
}
Ops are the operations over one configuration.
func (*Ops) AgeNeedsIdentity ¶ added in v0.94.0
AgeNeedsIdentity reports whether decrypting one of the SOPS files args name, relative to dir (the working directory when empty), takes an identity of secret.ageIdentities, from the vault, a file or the store.
func (*Ops) AgeNeedsVault ¶ added in v0.92.0
AgeNeedsVault reports whether decrypting one of the SOPS files args name, relative to dir (the working directory when empty), takes an age identity from the shared vault.
func (*Ops) Capture ¶ added in v0.119.0
func (o *Ops) Capture(ctx context.Context, dst Ref, opt CaptureOptions) (CaptureResult, error)
Capture runs the producer and writes the value it prints (one string of its JSON output with opt.JQ) to the shared vault's field first when one is given, then into the SOPS path in o.Encode, or as a Secret's .dockerconfigjson with opt.Docker. Every check (the references, the creation rule, the filter, the producer against Producers) runs before the producer does: a credential that is printed once is not spent on a call that could not store it. Neither the producer's stdout nor its stderr is ever answered.
func (*Ops) Compare ¶
Compare answers per key whether a and b hold the same values. Two single references compare as one value; two whole files key by key.
func (*Ops) CopyDocker ¶ added in v0.168.0
func (o *Ops) CopyDocker(ctx context.Context, src Ref, file string, d DockerConfig, nw *NewSecret) (int, error)
CopyDocker writes the one value src names as the password of a kubernetes.io/dockerconfigjson Secret in file: its stringData holds .dockerconfigjson, the registry's auths entry. An absent file starts as the Secret nw names. Every check runs before the value is read, so a producer's credential is not spent on a write that could not happen. It answers the length of the .dockerconfigjson written.
func (*Ops) CopyFile ¶
CopyFile copies a whole SOPS file to a new one, encrypted under the destination's creation rules, with a Kubernetes object's metadata.name and metadata.namespace rewritten when given. It answers the keys and their lengths.
func (*Ops) CopyToConsumer ¶
func (o *Ops) CopyToConsumer(ctx context.Context, src Ref, argv []string, in Stdin) (int, string, error)
CopyToConsumer runs an allowed consumer with the value on stdin, shaped by in. It answers the consumer's exit code and its output with the value redacted.
func (*Ops) CopyToGit ¶ added in v0.119.0
func (o *Ops) CopyToGit(ctx context.Context, src Ref, argv []string, user string) (int, string, error)
CopyToGit runs an allowed git operation with GIT_ASKPASS answering user and the value, which never reaches git's argv, its environment or a file. It answers git's exit code and its output with the value redacted.
func (*Ops) CopyToRemote ¶ added in v0.171.0
func (o *Ops) CopyToRemote(ctx context.Context, src Ref, f RemoteFile) (RemoteResult, error)
CopyToRemote writes one value into a file on a host over ssh, the value (in o.Encode, inside f's template) on ssh's stdin alone. Every check runs before the value is read; a source that resolves to nothing fails before ssh runs.
func (*Ops) CopyToSecret ¶ added in v0.81.0
CopyToSecret copies one value into a key of a Secret in a kind cluster, reached with the admin kubeconfig kind answers, which stays in memory like the value. It answers the value's length. Which contexts a caller may write to is the caller's to check.
func (*Ops) CopyValue ¶
CopyValue copies one value into a vault field or a path of a SOPS file, creating the item, field, file or key when absent. The destination vault or SOPS creation rule is checked before the value is read, so a producer's credential is not spent on a write that could not happen. It answers the value's length.
func (*Ops) CopyValues ¶ added in v0.108.0
func (o *Ops) CopyValues(ctx context.Context, pairs []Pair, file string, nw *NewSecret) ([]Key, error)
CopyValues writes several values into a new SOPS file in one encryption: sops needs only the recipients of the file's creation rule, nothing is decrypted, so no age identity of the destination is needed. An absent file starts as the Secret nw names (an empty document when nil), a plaintext Secret skeleton is filled; an encrypted file is refused. Every path is checked against the creation rule before a value is read. It answers the keys and their lengths.
func (*Ops) Fingerprints ¶
Fingerprints are the keyed fingerprints of what r names, of the one value in o.Encode when an encoding is set.
func (*Ops) Handover ¶ added in v0.109.0
Handover reads every credential of creds now, so that a reference that does not answer, a name that is no variable's or a value that is empty or more than one line, which no variable carries, refuses the whole set before anything runs on it.
func (*Ops) Import ¶ added in v0.83.0
Import copies one field of a vault the person reads, outside the shared vault, into a field of the shared vault (creating the item or the field when absent), and answers the value's length. The source is read with the person's session, the destination written as the service account, or as the person in session mode.
func (*Ops) ImportAge ¶ added in v0.112.0
ImportAge imports the age identity of recipient from src into the shared vault's item of that recipient (AgeItemRef) and answers the destination and the stored identity's length. The source is an identity or an identity file's text (comment lines above the AGE-SECRET-KEY-1… line, keys.txt as age-keygen writes it); only the identity whose public key is recipient is stored, and a source holding none is refused before anything is written, so another key never becomes a recipient's identity.
func (*Ops) Items ¶ added in v0.147.0
Items lists the items of vault, one of Ops.ListVaults: titles and metadata, with opt.Fields each field's label, type and length, with opt.EnvKeys each KEY of a field's KEY=VALUE lines and its value's length. A value is read in this process for its length alone and answered nowhere.
func (*Ops) ListVaults ¶ added in v0.147.0
ListVaults are the vaults items lists: secret.vault, secret.vaults and secret.ageVaults, those beekeeper reads.
func (*Ops) ReadVaults ¶ added in v0.147.0
ReadVaults are the vaults a value is read from: Vault and Vaults.
func (*Ops) Recipients ¶ added in v0.109.0
Recipients answers, for a directory, every age recipient of the creation rules of the .sops.yaml nearest above it and, for a SOPS file, the file's recipients (its metadata when encrypted, else its creation rule's), each with where its identity is: sops' own sources, an entry of secret.ageIdentities, the shared vault's item per recipient (checked by the vault's item listing, metadata only), or none. No value is read.
func (*Ops) Reveal ¶ added in v0.114.0
Reveal answers the leaves of a SOPS file under paths in plaintext: every scalar a path names, or under it. Each one is classified first, and one that looks secret refuses the whole call, named by its path and the reason, never its value.
func (*Ops) RevealTo ¶ added in v0.114.0
func (o *Ops) RevealTo(ctx context.Context, file, path string, dst Ref, write bool) (RevealResult, error)
RevealTo writes the configuration under path of a SOPS file into dst, a path of a plaintext YAML file (created when absent, its other keys kept), and answers the leaves written, which it never prints. Without write it answers what it would write. A destination that holds the same answers unchanged and writes nothing.
func (*Ops) RotateGenerated ¶ added in v0.73.0
func (o *Ops) RotateGenerated(ctx context.Context, ref Ref, files []string, ix *guard.Index, length int, charset string) (Rotation, error)
RotateGenerated replaces a value beekeeper generated: a new one into the shared vault's field first, then into every path of files that carried the old one, matched by fingerprint. Index matches and learns the values.
func (*Ops) RotateIssued ¶ added in v0.73.0
func (o *Ops) RotateIssued(ctx context.Context, ref Ref, files []string, ix *guard.Index) (Rotation, error)
RotateIssued carries a value a third party issued, which the person put into the shared vault's field, into every path of files that carried the field's old value: the one the index fingerprinted.
func (*Ops) RotatePlatform ¶ added in v0.73.0
func (o *Ops) RotatePlatform(ctx context.Context, r PlatformRef, reason string, dryRun bool) (string, error)
RotatePlatform rotates a platform manager credential with the manager's own rotation, run on the host: platformctl reconciles the capability with --rotate, the manager writes the new value into the installation's SOPS files in a pull request, and nothing is decrypted here. dryRun shows the files that hold it instead. It answers platformctl's output, redacted.
func (*Ops) SecretFingerprint ¶ added in v0.111.0
SecretFingerprint is the keyed fingerprint of one key of a Secret in a kind cluster, read with the admin kubeconfig kind answers: a delivery is checked against Ops.Fingerprints of its source without a value read. Which contexts a caller may read is the caller's to check.
func (*Ops) SecretKeys ¶ added in v0.130.0
func (o *Ops) SecretKeys(ctx context.Context, file string, opt SecretKeysOptions) ([]CaptureResult, error)
SecretKeys writes the values opt.Produce answers into the keys of the Kubernetes Secret in the SOPS file, under stringData, in one sops write. Every check (the file is a Secret or absent with opt.New, the creation rule encrypts each key, no key is taken without opt.Replace) runs before the producer does. It answers each written key's length and keyed fingerprint, never a value.
func (*Ops) Set ¶
Set generates a value, or takes opt.Literal, and writes it to the shared vault's field first when one is given, then into the SOPS path, then into a lab's Secret and a consumer's stdin when given, these three in o.Encode. A value without a vault field lives in the SOPS file alone.
func (*Ops) SetSOPSValue ¶
SetSOPSValue writes v into a path of a SOPS file, checking the creation rule before encrypting the document.
func (*Ops) Setup ¶ added in v0.83.0
Setup creates the shared vault when absent and a service account that reads and writes it, and writes the account's token to tokenFile (0600). It runs op as the person: the caller's own signed-in session, the one thing a service account cannot do. The token goes from op's stdout to the file and nowhere else.
func (*Ops) StoreFields ¶ added in v0.125.0
func (o *Ops) StoreFields(ctx context.Context, vault, item string, fields []ItemField) ([]Stored, error)
StoreFields writes fields into the item titled item of vault in one op call, the item or a field created when absent, and answers each field's reference, length and fingerprint. Every field is checked before any is written: a label or value that is empty, a value or the item over its bound, a vault not the shared one.
func (*Ops) StoreValue ¶ added in v0.118.0
StoreValue writes v into the vault field dst, the item or the field created when absent, and answers the field, the value's length and its fingerprint.
func (*Ops) Unset ¶ added in v0.114.0
func (o *Ops) Unset(ctx context.Context, file string, paths []string, write bool) (UnsetResult, error)
Unset removes paths from a SOPS file with sops unset in beekeeper's process: the file keeps its recipients, sops renews its MAC and lastmodified. A path the file holds no longer is answered absent, so a second run removes nothing; without write nothing is removed. It answers the key names the file keeps, never a value.
type Pair ¶ added in v0.108.0
Pair is one value of a copy into a new file: the reference it is read from and the path it takes there.
type PlatformRef ¶ added in v0.73.0
type PlatformRef struct {
Installation, Capability, Name string
}
PlatformRef is a credential the platform manager generates: platform://<installation>/<capability>/<name>, the name as the manager's dry run lists its generated secrets.
func ParsePlatformRef ¶ added in v0.73.0
func ParsePlatformRef(s string) (PlatformRef, error)
ParsePlatformRef reads a platform:// reference.
func (PlatformRef) String ¶ added in v0.73.0
func (r PlatformRef) String() string
type Producer ¶ added in v0.168.2
type Producer struct {
Words []string
// Options are the options it takes, exactly as spelled; true takes a
// value, as the next word or after "=".
Options map[string]bool
// Operand, when set, accepts the one operand it takes.
Operand func(string) bool
}
Producer is a command a cmd:// reference and secret capture may run: the words its argv starts with and every option it may take after them.
type Recipient ¶ added in v0.109.0
type Recipient struct {
// Rule is the creation rule's path_regex, "(every file)" for one
// without, or the file whose recipients are answered.
Rule string `json:"rule"`
Recipient string `json:"recipient"`
// Identity is the source of the recipient's identity: sops' own
// sources, the entry of secret.ageIdentities, the shared vault's item,
// or [None] with what is missing.
Identity string `json:"identity"`
}
Recipient is one age recipient of a .sops.yaml creation rule or of a SOPS file, with where its identity is.
type Ref ¶
type Ref struct {
Op string
Store string
Kube KubeTarget
Plain string
Cmd string
File string
Path string
}
Ref names a value or a set of values: an op:// field of the shared vault (with #<KEY> one KEY=VALUE line of an env-style field), a key of a Kubernetes Secret as a source (k8s://<context>/ <namespace>/<name>/<key>, Path then one value inside the document the key holds), one value of a plain file on the host as a source (file://<absolute path>#<path>, the file in Plain), a value an allowed producer generates as a source (cmd://<command>#<path>, its words in Cmd), a credential-store entry (store://<entry>[#<field>], its entry in Store and attribute in Path), a SOPS file, or one path in a SOPS file (file#a.b.c, sops:// in front optional).
func (Ref) IsKube ¶ added in v0.115.0
IsKube is whether the reference names a key of a Kubernetes Secret.
func (Ref) IsSource ¶ added in v0.149.0
IsSource is whether the reference names a value beekeeper only reads: a key of a Kubernetes Secret, a plain file, a credential-store entry or a producer's output.
type RemoteFile ¶ added in v0.171.0
type RemoteFile struct {
User string
Host string
Port string
Path string
// Mode is the file's octal mode, 0600 when empty.
Mode string
// Owner is user[:group]; empty keeps the writing user's (root under --sudo).
Owner string
// Sudo runs the write under sudo -n, by the host's own sudo rules.
Sudo bool
// Template is the file's content with the value at TemplateValue;
// empty writes the value alone.
Template string
}
RemoteFile is a file on a host reached by ssh that one value is written into: its path, mode and owner, and whether the write runs under sudo.
func ParseRemoteFile ¶ added in v0.171.0
func ParseRemoteFile(s string) (RemoteFile, error)
ParseRemoteFile reads ssh://[<user>@]<host>[:<port>]/<absolute path>: a host that is no ssh option and an absolute, clean path of plain characters, so nothing in either reaches the remote shell but a file name.
func (RemoteFile) Argv ¶ added in v0.171.0
func (f RemoteFile) Argv(n int) []string
Argv is the ssh command line that writes n bytes read on its stdin into f: no TTY, no prompt, the host after "--", and the remote command a fixed script with every argument quoted. The value is never in it.
func (RemoteFile) Check ¶ added in v0.171.0
func (f RemoteFile) Check() error
Check refuses a mode, an owner or a template beekeeper would not write: every check runs before the value is read.
func (RemoteFile) Script ¶ added in v0.171.0
func (f RemoteFile) Script(n int) string
Script is the remote command that writes n bytes from stdin into f: a temp file next to the target under umask 077, its length checked against n (a dropped connection ends the stream early), owner then mode set (chown clears setuid and setgid, so chmod comes last), then moved into place. A target that is a directory is refused before the write and again before the move, which would put the file inside it. A failure or a signal removes the temp file and leaves the target as it was; on success it prints nothing.
The login shell of the ssh user parses the command before sh runs it: "sh -c '<script>'" with the script holding no backslash, newline or "!", and each of its own single quotes closed, escaped and reopened outside the quoted parts, reads the same in a POSIX shell, fish and csh.
func (RemoteFile) String ¶ added in v0.171.0
func (f RemoteFile) String() string
type RemoteResult ¶ added in v0.171.0
type RemoteResult struct {
File string `json:"file"`
Mode string `json:"mode"`
Owner string `json:"owner,omitempty"`
Bytes int `json:"bytes"`
Length int `json:"length"`
Fingerprint string `json:"fingerprint"`
}
RemoteResult is what a remote write answers: where, how and how much, and the value's keyed fingerprint, never the value.
type RevealResult ¶ added in v0.114.0
type RevealResult struct {
To string `json:"to"`
Paths []string `json:"paths"`
Written bool `json:"written"`
Unchanged bool `json:"unchanged"`
}
RevealResult is what reveal --to answers: the destination, the leaves it carries, and whether it was written or held them already.
type Rotation ¶ added in v0.73.0
type Rotation struct {
Ref string `json:"ref"`
Fingerprint string `json:"fingerprint"`
Carriers []Carrier `json:"carriers"`
}
Rotation is what rotate answers: the rotated reference, the new value's fingerprint and the SOPS paths that carry it now.
type Runner ¶
type Runner func(ctx context.Context, dir string, env []string, stdin io.Reader, name string, args ...string) ([]byte, error)
Runner runs a credential tool in dir with stdin, its environment plus env, and returns its stdout. Its error must carry nothing the tool printed but a redacted first line.
type SecretApplier ¶ added in v0.81.0
SecretApplier writes value into one key of a Secret in the cluster a kubeconfig reaches, the Secret's other keys kept.
type SecretKeysOptions ¶ added in v0.130.0
type SecretKeysOptions struct {
// Keys are the Secret's keys the values may take, in the order
// answered; a key the producer answers no value for stays as it is.
Keys []string
// New is the Secret an absent file starts as; nil refuses an absent
// file.
New *NewSecret
// Replace overwrites keys the Secret holds already; without it such a
// key refuses before the producer runs.
Replace bool
// Produce makes the values, each under one of Keys. It runs once,
// after every check passed: a credential handed out once is not spent
// on a call that could not store it.
Produce func(context.Context) (map[string]string, error)
}
SecretKeysOptions are the Secret a set of produced values goes into.
type SecretKeysPlan ¶
type SecretKeysPlan struct {
File string `json:"file"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Recipients []string `json:"recipients"`
Keys []string `json:"keys"`
}
SecretKeysPlan describes a write using public metadata and key names only.
func PlanSecretKeys ¶
func PlanSecretKeys(file string, keys []string, replace bool) (*SecretKeysPlan, error)
PlanSecretKeys checks an existing Secret and its creation rule without decrypting it, reading an identity, invoking a tool or writing any file. It does not prove access to a recipient's private identity.
type SecretReader ¶ added in v0.111.0
SecretReader reads one key of a Secret in the cluster a kubeconfig reaches.
type SetOptions ¶ added in v0.95.0
type SetOptions struct {
Length int
Charset string
// Literal is a known, public value written instead of a generated one
// (a GitHub App's client ID beside its client secret); one with the
// shape of a credential is refused.
Literal string
Vault Ref
Secret *KubeTarget
Consumer []string
Stdin Stdin
// New is the Secret a file absent so far starts as, its name and
// namespace; nil starts an empty document.
New *NewSecret
}
SetOptions are what set draws and where the value goes besides the SOPS path: the shared vault's field first, a lab's Secret and a consumer's stdin after it. Each is optional; the value never leaves the process otherwise.
type SetResult ¶ added in v0.95.0
type SetResult struct {
Key string `json:"key"`
Length int `json:"length"`
Fingerprint string `json:"fingerprint"`
Code int `json:"code,omitempty"`
Output string `json:"output,omitempty"`
}
SetResult is what set answers: the value's fingerprint and, with a consumer, its exit code and its output with the value redacted.
type Setup ¶ added in v0.83.0
type Setup struct {
Vault string `json:"vault"`
VaultID string `json:"vaultId"`
VaultCreated bool `json:"vaultCreated"`
ServiceAccount string `json:"serviceAccount"`
TokenFile string `json:"tokenFile"`
TokenBytes int `json:"tokenBytes"`
}
Setup is what Ops.Setup did: the shared vault, whether it created it, the service account and the length of its token, never the token.
type SigninCause ¶ added in v0.108.0
type SigninCause int
SigninCause is why a sign-in failed, as the keeper tells it from the command's error and the credential store's state when the command ran.
const ( // SigninUnknown is a failure with no known pattern. SigninUnknown SigninCause = iota // SigninRejected is a password 1Password rejected while the credential // store answered: the entry the command reads is wrong or rotated. SigninRejected // SigninStoreLocked is a credential store that was locked. SigninStoreLocked // SigninStoreAbsent is a session bus with no credential store on it. SigninStoreAbsent // SigninStore is a credential store the command could not read, by the // command's own words. SigninStore // SigninNetwork is a network that did not reach 1Password. SigninNetwork // SigninTimeout is a command that did not finish within its bound. SigninTimeout // SigninCommand is a command that could not run at all. SigninCommand )
func ClassifySignin ¶ added in v0.108.0
func ClassifySignin(err error, store StoreState) SigninCause
ClassifySignin tells why a sign-in failed: from err, the command's failure, and store, the credential store's state when it ran. A store that was locked or absent is the cause whatever the command said: a helper that read no password reports what 1Password said to the empty one. A rejection counts with the store unlocked, or unknown.
func (SigninCause) Rejected ¶ added in v0.108.0
func (c SigninCause) Rejected() bool
Rejected reports whether the cause is one for the person: a rejection that no retry mends.
func (SigninCause) String ¶ added in v0.108.0
func (c SigninCause) String() string
type Stdin ¶ added in v0.96.0
Stdin shapes what a consumer reads: the value alone, or with Field set, the JSON object Template with the value at Field (garage json-api's request, for one).
type Store ¶ added in v0.98.0
type Store struct {
// Read prints the secret of the entry appended as its last argument.
Read []string
// Search prints the names of the entries matching the term appended as
// its last argument, one per line, never a value.
Search []string
}
Store is the person's own credential store, reached through the person's own commands: beekeeper never handles the store's password, and the store shows whatever unlock prompt it shows.
type StoreState ¶ added in v0.108.0
type StoreState int
StoreState is the state of the person's credential store on the session bus (the freedesktop Secret Service: KeePassXC, GNOME Keyring, KWallet), as CredentialStore reads it.
const ( // StoreUnknown is a store the keeper cannot ask: no session bus, or a // probe that failed. StoreUnknown StoreState = iota // StoreAbsent is a session bus nobody serves the Secret Service on: // the store's program is not up, or the store is no Secret Service. StoreAbsent // StoreLocked is a Secret Service whose every collection is locked. StoreLocked // StoreReady is a Secret Service with an unlocked collection. StoreReady )
func CredentialStore ¶ added in v0.108.0
func CredentialStore(ctx context.Context) (StoreState, error)
CredentialStore asks the session bus for the state of the person's credential store, without starting one: absent while nobody serves the Secret Service, locked while every collection is, ready with an unlocked collection. Unknown, with the error, where the bus cannot be asked.
func (StoreState) String ¶ added in v0.108.0
func (s StoreState) String() string
type Stored ¶ added in v0.118.0
type Stored struct {
Ref string `json:"ref"`
Bytes int `json:"bytes"`
Fingerprint string `json:"fingerprint"`
}
Stored is what a store wrote: the field, the value's length and its keyed fingerprint, never the value.
type Storer ¶ added in v0.118.0
Storer writes value into the vault field ref with the session env (OP_SESSION_<id>=<token>) and answers what it wrote.
type UnsetResult ¶ added in v0.114.0
type UnsetResult struct {
File string `json:"file"`
Removed []string `json:"removed"`
Absent []string `json:"absent"`
Kept []string `json:"kept"`
Written bool `json:"written"`
}
UnsetResult is what unset answers: the paths removed (or, in a dry run, to remove), those the file holds no longer, and the key names it keeps.
type VaultRequest ¶ added in v0.91.0
type VaultRequest struct {
Op string `json:"op"`
Name string `json:"name,omitempty"`
Token string `json:"token,omitempty"`
// Ref and Value are a store's field and what it gets.
Ref string `json:"ref,omitempty"`
Value string `json:"value,omitempty"`
// Item and Fields are a store-item's item (op://<vault>/<item>) and
// the fields it gets, in one op call.
Item string `json:"item,omitempty"`
Fields []ItemField `json:"fields,omitempty"`
}
VaultRequest is one ask of the keeper's socket.
type VaultState ¶ added in v0.91.0
type VaultState struct {
Unlocked bool `json:"unlocked"`
Since time.Time `json:"since,omitzero"`
Until time.Time `json:"until,omitzero"`
// Error is why the last sign-in failed for good, after its retries.
Error string `json:"error,omitempty"`
// Retrying is what the running sign-in waits on or retries after, and
// when it looks again; empty once it unlocked or failed for good.
Retrying string `json:"retrying,omitempty"`
// Dropped is why op stopped taking the last session, at DroppedAt;
// empty once a sign-in unlocked again.
Dropped string `json:"dropped,omitempty"`
DroppedAt time.Time `json:"droppedAt,omitzero"`
// Stored is what a store wrote, Fields what a store-item wrote.
Stored *Stored `json:"stored,omitempty"`
Fields []Stored `json:"fields,omitempty"`
}
VaultState is the keeper's answer.
func AskVault ¶ added in v0.91.0
func AskVault(path string, req VaultRequest) (VaultState, error)
AskVault sends req to the keeper at path and returns its state. The listener must be this very binary, run as this user (Peer): a session goes to beekeeper's broker and nowhere else.
func ReadState ¶ added in v0.93.0
func ReadState(path string) (VaultState, error)
ReadState reads the broker's vault state; locked when the file is absent.
Source Files
¶
- age.go
- askpass.go
- askpasspeer_linux.go
- capture.go
- document.go
- encode.go
- envkeys.go
- handover.go
- handover_linux.go
- intake.go
- items.go
- kube.go
- leafdoc.go
- ops.go
- peer_linux.go
- plain.go
- producer.go
- producerpath_unix.go
- recipients.go
- remote.go
- reveal.go
- rotate.go
- rules.go
- secret.go
- secretkeys.go
- secretplan.go
- setup.go
- shape.go
- signin.go
- store.go
- store_linux.go
- vault.go
- vaultsock.go
- write_conflict.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package secrettest is a fake sops and op for the tests of beekeeper secret: its "encryption" is base64 under a sops metadata block, so a test sees a plaintext value on disk as one and secret takes the file for a sops file, and its vault is a map.
|
Package secrettest is a fake sops and op for the tests of beekeeper secret: its "encryption" is base64 under a sops metadata block, so a test sees a plaintext value on disk as one and secret takes the file for a sops file, and its vault is a map. |