AnomalRoil 2c268d25a5
[FEATURE] Adding support for age.Plugin identities (#2960)
* Feat: support age plugin identities, including age-plugin-yubikey ones.

Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>

* Applying code review comments and adding test

Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>

---------

Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>
2024-10-07 13:21:03 +02:00

45 lines
1.0 KiB
Go

package age
import (
"context"
"filippo.io/age/plugin"
"github.com/gopasspw/gopass/internal/cui"
"github.com/gopasspw/gopass/internal/out"
"github.com/gopasspw/gopass/pkg/termio"
)
var pluginTerminalUI = &plugin.ClientUI{
DisplayMessage: func(name, message string) error {
out.Printf(context.Background(), "%s plugin: %s", name, message)
return nil
},
RequestValue: func(name, message string, _ bool) (string, error) {
var err error
defer func() {
if err != nil {
out.Warningf(context.Background(), "could not read value for age-plugin-%s: %v", name, err)
}
}()
secret, err := termio.AskForPassword(context.Background(), "secret", false)
if err != nil {
return "", err
}
return secret, nil
},
Confirm: func(name, message, yes, no string) (bool, error) {
rep, _ := cui.GetSelection(context.Background(), message, []string{yes, no})
if rep == yes {
return true, nil
}
return false, nil
},
WaitTimer: func(name string) {
out.Printf(context.Background(), "waiting on %s plugin...", name)
},
}