keysource

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 7 Imported by: ? 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: keysource / logic type: io job: the one grammar an app resolves a key argument through — a file, an environment variable, stdin or a prompt — with the rules that keep the material off disk and off the command line limits: yields bytes and reads nothing into a key; what a PEM means is the library's (-> ranke.ParseKeypair). Key-agnostic on purpose, so an age passphrase takes the same grammar

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSpec       = errors.New("keysource: unrecognised key source")
	ErrInline     = errors.New("keysource: key material was passed where a source was expected, so it has reached the process table, the shell history and any CI log — treat this key as compromised and rotate it")
	ErrPermission = errors.New("keysource: key file is readable by others (chmod 600 it)")
	ErrNoTTY      = errors.New("keysource: a prompt needs keysource.WithTTY, which a server must not grant")
	ErrEmpty      = errors.New("keysource: the source held nothing")
)

Functions

func Load

func Load(spec string, in io.Reader, opts ...Option) ([]byte, error)

Load is Parse then Read — the whole of what an app does once, turning one command-line argument into key material.

Types

type Kind

type Kind int

Kind is where material comes from.

const (
	KindFile   Kind = iota // a path, bare or file:-prefixed
	KindEnv                // env:NAME
	KindStdin              // stdin
	KindPrompt             // prompt, and only under WithTTY
)

type Option

type Option func(*Spec)

Option narrows or widens what Parse admits.

func WithTTY

func WithTTY() Option

WithTTY permits the "prompt" spelling. Grant it from a command a person runs, never from a server: a prompt blocks until someone types.

type Spec

type Spec struct {
	Kind Kind
	Name string // the path, or the environment variable's name; empty otherwise
	// contains filtered or unexported fields
}

Spec is a checked key source with nothing read yet, so a caller validates its argument at startup and fetches a rotating secret where it signs.

func Parse

func Parse(spec string, opts ...Option) (Spec, error)

Parse reads the grammar, touching no file and no terminal: a bare path or file:PATH for a mounted secret, env:NAME where the key must not reach disk, stdin for a pipeline already holding it, and prompt for a person, under WithTTY.

func (Spec) Read

func (s Spec) Read(in io.Reader) ([]byte, error)

Read fetches the material. in is where "stdin" reads from and where a prompt is answered, so a test drives both without a terminal.

Jump to

Keyboard shortcuts

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