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
- Variables
- func Copy(from, to string, overwrite bool) error
- func Delete(name string) error
- func Get(name string) (string, error)
- func KeyToFile() error
- func KeyToKeychain() (string, error)
- func KeychainTool() (string, error)
- func Passphrase() string
- func RefHelp() string
- func Rename(from, to string, overwrite bool) error
- func Resolve(ref string) (string, error)
- func SelfEnv() []string
- func Set(name, value string) error
- func ValidRef(ref string) bool
- type Info
- type Strength
Constants ¶
const MinPassphrase = 15
MinPassphrase is the shortest passphrase doctor accepts without a warning.
Variables ¶
var ErrExists = errors.New("secret already exists")
ErrExists is returned by Copy and Rename when the new name is taken and overwrite is false.
var ErrNotFound = errors.New("secret not found")
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.
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.
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
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 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
KeyToKeychain moves the vault key from vault.key into the keychain.
func KeychainTool ¶ added in v0.3.0
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 Rename ¶ added in v0.3.0
Rename moves the value of from to the name to, in one change of the vault.
func Resolve ¶
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.
Types ¶
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).