06da0a668a
Provide a password-store CLI that keeps pass's on-disk layout (<name>.gpg binary OpenPGP under $PASSWORD_STORE_DIR) but routes all encryption and decryption through a vault-plugin-secrets-gpg engine mount, so the GPG private key never lives on the client. - Implement init/show/ls/insert/generate/edit/rm/mv/cp/find/grep/git with pass-compatible flags and implicit `passv <name>`=show dispatch. - Resolve the recipient from a Vault ref: .gpg-id holds <mount>/<key> for passv-native stores, or a sibling .vault-id lets a store keep real GPG fingerprints in .gpg-id for dual gpg+Vault use. - mv/cp re-encrypt across differing recipients; same-recipient moves copy the ciphertext verbatim. - Ship the sibling build/packaging/CI: nfpm RPM to /usr/bin/passv (artifactapi rpm-internal on v* tag), Woodpecker PR/release pipelines, unit tests plus a real-Vault e2e that also proves dual gpg+Vault decryption. - README covers store creation, migrating a GPG pass store, and dual-mode.
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// decryptEntry resolves an entry's governing Vault key and decrypts its `.gpg`
|
|
// file through the engine.
|
|
func decryptEntry(s *store, v *vaultClient, name string) ([]byte, error) {
|
|
if !s.hasEntry(name) {
|
|
return nil, errf("Error: %s is not in the password store.", name)
|
|
}
|
|
ref, err := s.vaultRef(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ct, err := s.readCipher(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return v.decrypt(ref, ct)
|
|
}
|
|
|
|
// encryptEntry encrypts content for an entry using its governing Vault key and
|
|
// writes the `.gpg` file.
|
|
func encryptEntry(s *store, v *vaultClient, name string, content []byte) error {
|
|
ref, err := s.vaultRef(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
ct, err := v.encrypt(ref, content)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return s.writeCipher(name, ct)
|
|
}
|
|
|
|
// confirm asks a yes/no question on stderr, defaulting to no.
|
|
func confirm(prompt string) bool {
|
|
fmt.Fprintf(os.Stderr, "%s [y/N] ", prompt)
|
|
line, _ := bufio.NewReader(os.Stdin).ReadString('\n')
|
|
line = strings.ToLower(strings.TrimSpace(line))
|
|
return line == "y" || line == "yes"
|
|
}
|