mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-05-12 10:58:21 +00:00
commit
423dfb020c
4 changed files with 10 additions and 13 deletions
|
@ -32,8 +32,7 @@ var verifyCMD = &cobra.Command{
|
||||||
|
|
||||||
userPassword := viper.GetString("userPassword")
|
userPassword := viper.GetString("userPassword")
|
||||||
if userPassword == "" {
|
if userPassword == "" {
|
||||||
fmt.Print("Enter Password:")
|
pw, err := util.ReadPassword("Enter Password:")
|
||||||
pw, err := util.ReadPassword()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
return fmt.Errorf("Reading Password: %w", err)
|
return fmt.Errorf("Reading Password: %w", err)
|
||||||
|
|
|
@ -55,7 +55,7 @@ func GroupList(cmd *cobra.Command, args []string) error {
|
||||||
defer client.Logout(context.TODO())
|
defer client.Logout(context.TODO())
|
||||||
cmd.SilenceUsage = true
|
cmd.SilenceUsage = true
|
||||||
|
|
||||||
resources, err := client.GetGroups(ctx, &api.GetGroupsOptions{
|
groups, err := client.GetGroups(ctx, &api.GetGroupsOptions{
|
||||||
FilterHasUsers: users,
|
FilterHasUsers: users,
|
||||||
FilterHasManagers: managers,
|
FilterHasManagers: managers,
|
||||||
})
|
})
|
||||||
|
@ -65,14 +65,14 @@ func GroupList(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
data := pterm.TableData{columns}
|
data := pterm.TableData{columns}
|
||||||
|
|
||||||
for _, resource := range resources {
|
for _, group := range groups {
|
||||||
entry := make([]string, len(columns))
|
entry := make([]string, len(columns))
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch strings.ToLower(columns[i]) {
|
switch strings.ToLower(columns[i]) {
|
||||||
case "id":
|
case "id":
|
||||||
entry[i] = resource.ID
|
entry[i] = group.ID
|
||||||
case "name":
|
case "name":
|
||||||
entry[i] = shellescape.StripUnsafe(resource.Name)
|
entry[i] = shellescape.StripUnsafe(group.Name)
|
||||||
default:
|
default:
|
||||||
cmd.SilenceUsage = false
|
cmd.SilenceUsage = false
|
||||||
return fmt.Errorf("Unknown Column: %v", columns[i])
|
return fmt.Errorf("Unknown Column: %v", columns[i])
|
||||||
|
|
|
@ -53,8 +53,7 @@ func KeepassExport(cmd *cobra.Command, args []string) error {
|
||||||
cmd.SilenceUsage = true
|
cmd.SilenceUsage = true
|
||||||
|
|
||||||
if keepassPassword == "" {
|
if keepassPassword == "" {
|
||||||
fmt.Print("Enter Keepass Password:")
|
pw, err := util.ReadPassword("Enter Keepass Password:")
|
||||||
pw, err := util.ReadPassword()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
return fmt.Errorf("Reading Keepass Password: %w", err)
|
return fmt.Errorf("Reading Keepass Password: %w", err)
|
||||||
|
|
|
@ -17,11 +17,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadPassword reads a Password interactively or via Pipe
|
// ReadPassword reads a Password interactively or via Pipe
|
||||||
func ReadPassword() (string, error) {
|
func ReadPassword(prompt string) (string, error) {
|
||||||
fd := int(os.Stdin.Fd())
|
fd := int(os.Stdin.Fd())
|
||||||
var pass string
|
var pass string
|
||||||
if term.IsTerminal(fd) {
|
if term.IsTerminal(fd) {
|
||||||
fmt.Print("Enter Password:")
|
fmt.Print(prompt)
|
||||||
|
|
||||||
inputPass, err := term.ReadPassword(fd)
|
inputPass, err := term.ReadPassword(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -54,7 +54,7 @@ func GetClient(ctx context.Context) (*api.Client, error) {
|
||||||
|
|
||||||
userPassword := viper.GetString("userPassword")
|
userPassword := viper.GetString("userPassword")
|
||||||
if userPassword == "" {
|
if userPassword == "" {
|
||||||
cliPassword, err := ReadPassword()
|
cliPassword, err := ReadPassword("Enter Password:")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
return nil, fmt.Errorf("Reading Password: %w", err)
|
return nil, fmt.Errorf("Reading Password: %w", err)
|
||||||
|
@ -94,8 +94,7 @@ func GetClient(ctx context.Context) (*api.Client, error) {
|
||||||
}
|
}
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
var code string
|
var code string
|
||||||
fmt.Print("Enter TOTP:")
|
code, err := ReadPassword("Enter TOTP:")
|
||||||
code, err := ReadPassword()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
return http.Cookie{}, fmt.Errorf("Reading TOTP: %w", err)
|
return http.Cookie{}, fmt.Errorf("Reading TOTP: %w", err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue