mirror of
https://github.com/la5nta/pat
synced 2026-08-07 22:32:06 -04:00
Replace howeyc/gopass with golang.org/x/term
github.com/howeyc/gopass was archived in 2021, which led to the debian project to mark this as a release candidate bug (#1130525). Resolves #517
This commit is contained in:
parent
7068f947ad
commit
43788c1b73
5 changed files with 22 additions and 22 deletions
13
cli/init.go
13
cli/init.go
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/la5nta/pat/internal/cmsapi"
|
||||
"github.com/la5nta/pat/internal/debug"
|
||||
|
||||
"github.com/howeyc/gopass"
|
||||
"github.com/pd0mz/go-maidenhead"
|
||||
)
|
||||
|
||||
|
|
@ -68,11 +67,11 @@ func InitHandle(ctx context.Context, a *app.App, args []string) {
|
|||
fmt.Printf("\nThat's it! Basic configuration is set. For advanced settings, run '%s configure' or use the web gui.\n", os.Args[0])
|
||||
}
|
||||
|
||||
// promptPassword prompts the user to enter a password twice for confirmation
|
||||
func promptPassword() string {
|
||||
// promptNewPassword prompts the user to enter a password twice for confirmation
|
||||
func promptNewPassword() string {
|
||||
for {
|
||||
fmt.Println("\nPlease choose a password for your account (6-12 characters)")
|
||||
password1, err := gopass.GetPasswdPrompt("Enter password: ", true, os.Stdin, os.Stdout)
|
||||
password1, err := promptPassword("Enter password: ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
@ -81,7 +80,7 @@ func promptPassword() string {
|
|||
continue
|
||||
}
|
||||
|
||||
password2, err := gopass.GetPasswdPrompt("Confirm password: ", true, os.Stdin, os.Stdout)
|
||||
password2, err := promptPassword("Confirm password: ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
@ -140,7 +139,7 @@ func handleNewAccount(ctx context.Context, cfg *cfg.Config) {
|
|||
}
|
||||
|
||||
// Prompt for password
|
||||
password := promptPassword()
|
||||
password := promptNewPassword()
|
||||
|
||||
// Prompt for recovery email
|
||||
fmt.Println("\nWould you like to set a password recovery email? This is optional, but highly recommended.")
|
||||
|
|
@ -203,7 +202,7 @@ L:
|
|||
if cfg.SecureLoginPassword != "" {
|
||||
promptStr = promptStr[:len(promptStr)-2] + fmt.Sprintf(" [%s]: ", strings.Repeat("*", len(cfg.SecureLoginPassword)))
|
||||
}
|
||||
password, err := gopass.GetPasswdPrompt(promptStr, true, os.Stdin, os.Stdout)
|
||||
password, err := promptPassword(promptStr)
|
||||
switch {
|
||||
case err != nil:
|
||||
log.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/la5nta/pat/app"
|
||||
|
||||
"github.com/howeyc/gopass"
|
||||
)
|
||||
|
||||
type TerminalPrompter struct{}
|
||||
|
|
@ -49,7 +47,7 @@ func (t TerminalPrompter) Prompt(prompt app.Prompt) {
|
|||
}
|
||||
prompt.Respond(strings.Join(selected, ","), nil)
|
||||
case app.PromptKindPassword:
|
||||
passwd, err := gopass.GetPasswdPrompt(prompt.Message+": ", true, os.Stdin, os.Stdout)
|
||||
passwd, err := promptPassword(prompt.Message + ": ")
|
||||
prompt.Respond(string(passwd), err)
|
||||
case app.PromptKindBusyChannel:
|
||||
fmt.Println(prompt.Message + ":")
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import (
|
|||
"github.com/la5nta/pat/internal/debug"
|
||||
"github.com/la5nta/wl2k-go/fbb"
|
||||
"github.com/la5nta/wl2k-go/mailbox"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
func shiftArgs(s []string) (string, []string) {
|
||||
|
|
@ -86,6 +88,13 @@ func prompt(question, defaultValue string, options ...string) string {
|
|||
return prompt2(os.Stdout, question, defaultValue, options...)
|
||||
}
|
||||
|
||||
func promptPassword(prompt string) (string, error) {
|
||||
defer fmt.Fprintln(os.Stdout)
|
||||
fmt.Fprint(os.Stdout, prompt)
|
||||
passwd, err := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
return string(passwd), err
|
||||
}
|
||||
|
||||
func SplitFunc(c rune) bool {
|
||||
return unicode.IsSpace(c) || c == ',' || c == ';'
|
||||
}
|
||||
|
|
|
|||
6
go.mod
6
go.mod
|
|
@ -13,7 +13,6 @@ require (
|
|||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/harenber/ptc-go/v2 v2.2.4
|
||||
github.com/hashicorp/go-version v1.8.0
|
||||
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef
|
||||
github.com/kelseyhightower/envconfig v1.4.0
|
||||
github.com/la5nta/wl2k-go v1.0.1
|
||||
github.com/microcosm-cc/bluemonday v1.0.27
|
||||
|
|
@ -23,6 +22,7 @@ require (
|
|||
github.com/peterh/liner v1.2.2
|
||||
github.com/spf13/pflag v1.0.10
|
||||
golang.org/x/sync v0.19.0
|
||||
golang.org/x/term v0.30.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
@ -37,12 +37,10 @@ require (
|
|||
github.com/mattn/go-runewidth v0.0.19 // indirect
|
||||
github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.47.0 // indirect
|
||||
golang.org/x/mod v0.22.0 // indirect
|
||||
golang.org/x/net v0.49.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/sys v0.40.0 // indirect
|
||||
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7 // indirect
|
||||
golang.org/x/term v0.39.0 // indirect
|
||||
golang.org/x/tools v0.29.0 // indirect
|
||||
golang.org/x/vuln v1.1.4 // indirect
|
||||
)
|
||||
|
|
|
|||
12
go.sum
12
go.sum
|
|
@ -43,8 +43,6 @@ github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bP
|
|||
github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/howeyc/crc16 v0.0.0-20171223171357-2b2a61e366a6 h1:IIVxLyDUYErC950b8kecjoqDet8P5S4lcVRUOM6rdkU=
|
||||
github.com/howeyc/crc16 v0.0.0-20171223171357-2b2a61e366a6/go.mod h1:JslaLRrzGsOKJgFEPBP65Whn+rdwDQSk0I0MCRFe2Zw=
|
||||
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef h1:A9HsByNhogrvm9cWb28sjiS3i7tcKCkflWFEkHfuAgM=
|
||||
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
|
||||
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
|
||||
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
|
|
@ -86,12 +84,10 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
|||
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
|
||||
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
|
||||
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
||||
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
|
@ -100,8 +96,8 @@ golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
|||
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7 h1:FemxDzfMUcK2f3YY4H+05K9CDzbSVr2+q/JKN45pey0=
|
||||
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
|
||||
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
|
||||
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
|
||||
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
|
||||
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
|
||||
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
|
||||
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
|
||||
golang.org/x/vuln v1.1.4 h1:Ju8QsuyhX3Hk8ma3CesTbO8vfJD9EvUBgHvkxHBzj0I=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue