mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-05-12 02:58:20 +00:00
add password prompt
This commit is contained in:
parent
19f6fb3b0e
commit
ad91065c71
2 changed files with 9 additions and 1 deletions
1
go.mod
1
go.mod
|
@ -11,5 +11,6 @@ require (
|
|||
github.com/spf13/cobra v1.2.1
|
||||
github.com/spf13/viper v1.8.1
|
||||
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34 // indirect
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
|
||||
gopkg.in/ini.v1 v1.63.0 // indirect
|
||||
)
|
||||
|
|
|
@ -3,9 +3,11 @@ package util
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/speatzle/go-passbolt/api"
|
||||
"github.com/spf13/viper"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// GetClient gets a Logged in Passbolt Client
|
||||
|
@ -22,7 +24,12 @@ func GetClient(ctx context.Context) (*api.Client, error) {
|
|||
|
||||
userPassword := viper.GetString("userPassword")
|
||||
if userPassword == "" {
|
||||
return nil, fmt.Errorf("userPassword is not defined")
|
||||
fmt.Print("Enter Password:")
|
||||
bytepw, err := term.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Reading Password: %w", err)
|
||||
}
|
||||
userPassword = string(bytepw)
|
||||
}
|
||||
|
||||
client, err := api.NewClient(nil, "", serverAddress, userPrivateKey, userPassword)
|
||||
|
|
Loading…
Add table
Reference in a new issue