aboutsummaryrefslogtreecommitdiff
path: root/cli.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-01-30 02:08:55 +0700
committerShulhan <ms@kilabit.info>2024-01-30 02:08:55 +0700
commit267821d95857ed51e2e5e23556884c383d94ca24 (patch)
tree7b13ed4a6eb1947c63f6dd5236dc2c23b662282e /cli.go
parent77ba620765a5682e05169be8b8740df925f612c8 (diff)
downloadgotp-267821d95857ed51e2e5e23556884c383d94ca24.tar.xz
cli: ask for passphrase when removing or renaming label
Even though rename does not read the encrypted secret, as long as the private key is in use, it should ask for passphrase. The remove operation allow only the one that know the private key can modify the issuer.
Diffstat (limited to 'cli.go')
-rw-r--r--cli.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cli.go b/cli.go
index e3b6d77..34127ca 100644
--- a/cli.go
+++ b/cli.go
@@ -205,6 +205,11 @@ func (cli *Cli) Remove(label string) (err error) {
return fmt.Errorf(`%s: %q not exist`, logp, label)
}
+ err = cli.cfg.loadPrivateKey()
+ if err != nil {
+ return fmt.Errorf(`%s: %w`, logp, err)
+ }
+
delete(cli.cfg.Issuers, label)
err = cli.cfg.save()
@@ -285,6 +290,11 @@ func (cli *Cli) Rename(label, newLabel string) (err error) {
ok bool
)
+ err = cli.cfg.loadPrivateKey()
+ if err != nil {
+ return fmt.Errorf(`%s: %w`, logp, err)
+ }
+
label = strings.TrimSpace(label)
label = strings.ToLower(label)
rawValue, ok = cli.cfg.Issuers[label]