forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Pinentry CLI fallback (gopasspw#1697)
Fixes gopasspw#1655 RELEASE_NOTES=[ENHANCEMENT] Add Pinentry CLI fallback Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
- Loading branch information
1 parent
6974917
commit 670630d
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gopasspw/gopass/pkg/termio" | ||
) | ||
|
||
// Client is pinentry CLI drop-in | ||
type Client struct{} | ||
|
||
// New creates a new client | ||
func New() (*Client, error) { | ||
return &Client{}, nil | ||
} | ||
|
||
// Close is a no-op | ||
func (c *Client) Close() {} | ||
|
||
// Confirm is a no-op | ||
func (c *Client) Confirm() bool { | ||
return true | ||
} | ||
|
||
// Set is a no-op | ||
func (c *Client) Set(string, string) error { | ||
return nil | ||
} | ||
|
||
// Option is a no-op | ||
func (c *Client) Option(string) error { | ||
return nil | ||
} | ||
|
||
// GetPin prompts for the pin in the termnial and returns the output | ||
func (c *Client) GetPin() ([]byte, error) { | ||
pw, err := termio.AskForPassword(context.TODO(), "Please enter your PIN") | ||
if err != nil { | ||
return nil, err | ||
} | ||
return []byte(pw), nil | ||
} |