Documentation
¶
Overview ¶
Package signingcli provides the shareable `sign` and `keys` Cobra commands over gitlab.com/phpboyscout/go/signing. Real signing/verification logic lives in go/signing; this module owns only the command surface so GTB and the standalone `sigillum` CLI can both attach it without a cycle.
Index ¶
- Variables
- func NewCmdKeys(log Logger) *cobra.Command
- func NewCmdKeysGenerate(log Logger) *cobra.Command
- func NewCmdKeysMinisign(log Logger) *cobra.Command
- func NewCmdKeysMint(log Logger) *cobra.Command
- func NewCmdKeysPublish(log Logger) *cobra.Command
- func NewCmdKeysWKD(log Logger) *cobra.Command
- func NewCmdSign(log Logger) *cobra.Command
- func RegisterBackendFlags(fs *pflag.FlagSet)
- func RegisterKeysCommand(ctor CommandConstructor)
- func RegisterSignCommand(ctor CommandConstructor)
- func RegisterSignLane(lane SignLane)
- func ResolveSigner(ctx context.Context, fs *pflag.FlagSet, selector, keyID string) (crypto.Signer, string, error)
- type CommandConstructor
- type Logger
- type SignLane
- type SignRequest
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyAlreadyPublished is returned when a key is already // published at the same path with different content. Published keys // are add-only: consumers pin them, so changing one under a // consumer's feet is exactly what must never happen. ErrKeyAlreadyPublished = errors.NewSentinel("signing-cli.key_already_published", "a different key is already published at this path") // ErrInvalidProject is returned when --project is not a safe path // segment. ErrInvalidProject = errors.NewSentinel("signing-cli.invalid_project", "project name must be lowercase alphanumeric with dots, dashes or underscores") // ErrInvalidStatus is returned when --status is not one of the // known lifecycle states. ErrInvalidStatus = errors.NewSentinel("signing-cli.invalid_status", "unknown status") )
var ErrKeyFileExists = errors.NewSentinel("signing-cli.key_file_exists", "output file already exists")
ErrKeyFileExists is returned when a key output file already exists and --force was not supplied. Overwriting a private key in place could silently destroy the only copy of a signing key, so the default is to refuse.
Functions ¶
func NewCmdKeys ¶
NewCmdKeys returns the top-level `keys` command group with its subcommands attached, including any a signature format registered.
func NewCmdKeysGenerate ¶
NewCmdKeysGenerate returns the `keys generate` subcommand. Generates a fresh keypair entirely in-process (no shell-out, no external dependencies) and writes both halves to disk. Used during onboarding for the rotation-authority key and the tutorial / local signing key.
func NewCmdKeysMinisign ¶ added in v0.2.0
NewCmdKeysMinisign returns the `keys minisign` subcommand: emit the minisign public key for an Ed25519 signer.
This is the counterpart to `keys mint`, which emits an armored OpenPGP public key. The consumers of an artefact signature do not speak OpenPGP, so they need this form instead.
func NewCmdKeysMint ¶
NewCmdKeysMint returns the `keys mint` subcommand. Wraps an existing signer (KMS or local PEM file) in OpenPGP framing and writes the armored public half to a file.
func NewCmdKeysPublish ¶ added in v0.3.0
NewCmdKeysPublish returns the `keys publish` subcommand.
func NewCmdKeysWKD ¶
NewCmdKeysWKD returns the `keys wkd` subcommand. Reads one or more armored OpenPGP public keys and emits a Web Key Directory tree (per draft-koch-openpgp-webkey-service §3.1) ready to upload to a static host.
Spec: https://gitlab.com/phpboyscout/go-tool-base/-/wikis/specs/0069-keys-wkd-command
func NewCmdSign ¶
NewCmdSign returns the top-level `sign` command, with a --format lane for each registered signature format and any command a format attaches beneath it.
func RegisterBackendFlags ¶ added in v0.7.0
RegisterBackendFlags adds the flags of every compiled-in backend that has its own, such as aws-kms's --kms-region, to fs. A format command that takes --backend calls it so its backends are configured as sign's are.
func RegisterKeysCommand ¶ added in v0.7.0
func RegisterKeysCommand(ctor CommandConstructor)
RegisterKeysCommand attaches a command under keys, such as a format's own key generator. Call it from init().
func RegisterSignCommand ¶ added in v0.7.0
func RegisterSignCommand(ctor CommandConstructor)
RegisterSignCommand attaches a command under sign, such as sign image. Call it from init().
func RegisterSignLane ¶ added in v0.7.0
func RegisterSignLane(lane SignLane)
RegisterSignLane adds a --format lane to the sign command. Call it from init().
Panics on an empty Format, a nil Sign, a Format already registered, or a second Default lane. Each is a programmer error that should never reach a deployed binary.
func ResolveSigner ¶ added in v0.7.0
func ResolveSigner(ctx context.Context, fs *pflag.FlagSet, selector, keyID string) (crypto.Signer, string, error)
ResolveSigner resolves a --backend selector and constructs its signer for keyID. fs is the flag set RegisterBackendFlags populated. The returned string identifies the backend in log lines.
Types ¶
type CommandConstructor ¶ added in v0.7.0
CommandConstructor builds a command a format attaches to the tree.
type Logger ¶
type Logger interface {
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
}
Logger is the minimal logging surface the commands need. Both a *slog.Logger and GTB's logger.Logger satisfy it structurally, so callers pass their logger directly — no adapter.
type SignLane ¶ added in v0.7.0
type SignLane struct {
// Format is the --format value that selects the lane.
Format string
// Summary describes what the lane writes, in the --format help.
Summary string
// Default makes the lane the --format default when several are
// registered. At most one lane may set it.
Default bool
// Flags adds the flags only this lane uses. Choosing another lane while
// one of them is set is refused. Nil when the lane has none.
Flags func(fs *pflag.FlagSet)
// Sign writes the signature. The lane reads its own flags from
// cmd.Flags().
Sign func(cmd *cobra.Command, log Logger, req SignRequest) error
}
SignLane is one --format value of the sign command.