File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 77 "github.com/99designs/keyring"
88 log "github.com/sirupsen/logrus"
99 "github.com/spf13/cobra"
10+ "golang.org/x/crypto/ssh/terminal"
1011)
1112
1213var (
1920
2021var keyringDefaults = keyring.Config {
2122 FileDir : fmt .Sprintf ("~/.%s/keys/" , projectName ),
23+ FilePasswordFunc : fileKeyringPassphrasePrompt ,
2224 ServiceName : projectName ,
2325 KeychainName : projectName ,
2426 LibSecretCollectionName : projectNameWithoutHyphen ,
@@ -44,6 +46,21 @@ var rootCmd = &cobra.Command{
4446 Run : func (cmd * cobra.Command , args []string ) {},
4547}
4648
49+ // Get passphrase prompt (copied from https://github.com/99designs/aws-vault)
50+ func fileKeyringPassphrasePrompt (prompt string ) (string , error ) {
51+ if password , ok := os .LookupEnv ("CF_VAULT_FILE_PASSPHRASE" ); ok {
52+ return password , nil
53+ }
54+
55+ fmt .Fprintf (os .Stderr , "%s: " , prompt )
56+ b , err := terminal .ReadPassword (int (os .Stdin .Fd ()))
57+ if err != nil {
58+ return "" , err
59+ }
60+ fmt .Println ()
61+ return string (b ), nil
62+ }
63+
4764func init () {
4865 log .SetLevel (log .WarnLevel )
4966
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ require (
1010 github.com/pelletier/go-toml v1.9.5
1111 github.com/sirupsen/logrus v1.9.0
1212 github.com/spf13/cobra v1.5.0
13- golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
13+ golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
1414 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
1515 golang.org/x/tools/gopls v0.9.5
1616)
Original file line number Diff line number Diff line change @@ -121,8 +121,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U
121121golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 /go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI =
122122golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 /go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto =
123123golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 /go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc =
124- golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY =
125- golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d /go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4 =
124+ golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM =
125+ golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 /go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4 =
126126golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA =
127127golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e /go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA =
128128golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e /go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk =
You can’t perform that action at this time.
0 commit comments