vault

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: AGPL-3.0 Imports: 21 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 vault stores secrets (passwords, key passphrases, tokens) encrypted with AES-256-GCM, each bound to its name. The key is derived with scrypt from $KOMANDO_VAULT_PASS when set (N=2^17, r=8, p=1: the OWASP minimum), otherwise from a random 32-byte key file (vault.key, mode 0600).

Index

Constants

View Source
const MinPassphrase = 15

MinPassphrase is the shortest passphrase doctor accepts without a warning.

Variables

View Source
var ErrExists = errors.New("secret already exists")

ErrExists is returned by Copy and Rename when the new name is taken and overwrite is false.

View Source
var ErrNotFound = errors.New("secret not found")
View Source
var PassphraseN = 1 << 17

PassphraseN is the scrypt cost for passphrase vaults (OWASP Password Storage Cheat Sheet: N=2^17, r=8, p=1). Tests lower it.

View Source
var RefGuard func(kind, name string) error

RefGuard, when set, is asked before Resolve reads a file on this computer (kind "file") or an environment variable (kind "env") for a reference. komando's CLI sets it, so an AI agent cannot point a reference, which komando sends to a server as a password, at secrets it must not have.

View Source
var Refs = []string{
	"secret:NAME (komando's vault)",
	"env:VAR",
	"file:PATH",
	"op://VAULT/ITEM/FIELD (1Password Connect)",
	"bw://ITEM/FIELD (Bitwarden, Vaultwarden)",
	"kdbx:FILE#GROUP/ENTRY[#FIELD] (KeePass, KeePassXC)",
	"vault:PATH#FIELD (HashiCorp Vault or OpenBao, KV)",
	"aws-sm:NAME[#JSON_KEY] (AWS Secrets Manager)",
	"gcp-sm:NAME[@PROJECT] (Google Secret Manager)",
}

Refs are the kinds of secret reference komando understands, with an example each, for help texts and errors.

Functions

func Copy added in v0.3.0

func Copy(from, to string, overwrite bool) error

Copy stores the value of from under the name to as well. The value is decrypted and sealed again inside the vault (each value is bound to its name) and never leaves this package.

func Delete

func Delete(name string) error

func Get

func Get(name string) (string, error)

func KeyToFile added in v0.3.0

func KeyToFile() error

KeyToFile moves the vault key back from the keychain into vault.key.

func KeyToKeychain added in v0.3.0

func KeyToKeychain() (string, error)

KeyToKeychain moves the vault key from vault.key into the keychain.

func KeychainTool added in v0.3.0

func KeychainTool() (string, error)

KeychainTool says which tool keeps the key here, or why there is none.

func Passphrase added in v0.2.0

func Passphrase() string

Passphrase returns $KOMANDO_VAULT_PASS and removes it from this process's environment, so programs komando starts (kubectl, credential plugins, VPN clients, docker) never inherit it.

func RefHelp added in v0.2.0

func RefHelp() string

RefHelp is the hint for an invalid reference.

func Rename added in v0.3.0

func Rename(from, to string, overwrite bool) error

Rename moves the value of from to the name to, in one change of the vault.

func Resolve

func Resolve(ref string) (string, error)

Resolve turns a reference into a value:

secret:<name>        -> komando's vault
env:<VAR>            -> environment variable
file:<path>          -> file contents (trailing newline trimmed)
op://v/item/field    -> 1Password Connect (OP_CONNECT_HOST, OP_CONNECT_TOKEN)
bw://item/field      -> Bitwarden or Vaultwarden, decrypted here (KOMANDO_BW_*)
kdbx:file#group/entry[#field] -> a KeePass file (KOMANDO_KDBX_PASSWORD / KOMANDO_KDBX_KEYFILE)
vault:path#field     -> HashiCorp Vault / OpenBao KV (VAULT_ADDR and a token, as the CLI uses them)
aws-sm:name[#key]    -> AWS Secrets Manager (the usual AWS credentials; a JSON key when given)
gcp-sm:name[@project]-> Google Secret Manager, latest version (application-default credentials)

komando talks to those services itself (internal/cloud); the login stays with the person and komando never stores the values.

func SelfEnv added in v0.2.0

func SelfEnv() []string

SelfEnv is the environment for komando's own background processes (`vpn serve`, `tunnel serve`), which need the vault.

func Set

func Set(name, value string) error

func ValidRef added in v0.2.0

func ValidRef(ref string) bool

ValidRef reports whether ref has a known form.

Types

type Info

type Info struct {
	Name      string    `json:"name"`
	UpdatedAt time.Time `json:"updated_at"`
}

func List

func List() ([]Info, error)

type Strength added in v0.2.0

type Strength struct {
	Mode       string `json:"mode"`
	ScryptN    int    `json:"scrypt_n"`
	ShortPass  bool   `json:"short_passphrase,omitempty"`
	OldKDF     bool   `json:"old_kdf,omitempty"`
	NoVaultYet bool   `json:"no_vault_yet,omitempty"`
}

Strength describes the vault's protection for `komando doctor`: the mode, the scrypt cost and, for a passphrase, whether it is long enough (NIST SP 800-63B asks for 15 characters when it is the only factor).

func Check added in v0.2.0

func Check() (Strength, error)

Jump to

Keyboard shortcuts

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