-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch secret store to the keyring secret store #4754
Closed
Closed
Changes from 115 commits
Commits
Show all changes
120 commits
Select commit
Hold shift + click to select a range
28859d2
initial work on keyringKeybase
poldsam 10fcf0c
Created a keybase implmentation based on keyring
poldsam aa0441f
Added the lazykey keybase for keyring
poldsam 3455769
First test. Not yet working
poldsam 75e4272
Temporary bandaid fix for testing
zmanian 20d26e3
fixes for keybase tests passed
poldsam df118b2
adding another tests passed
poldsam 12cd140
adding another tests passed
poldsam 040f3a4
adding another tests passed
poldsam 3e36d53
adding more tests passed
poldsam 7381a97
sorting keys in alphabetical order
poldsam 49ef05d
Merge commit with master
zmanian 650ef8b
Apply Formating
zmanian 630aec0
implementing updated to the keybase interface
poldsam f82f871
implementing interface for the lazy keybase keyring
poldsam c4bf95d
started migration command
poldsam 43e4d6c
changing variable name to camel case format
poldsam 0b9995d
starting migrate command testing
poldsam 98caf12
Fix tests for migration
zmanian a0e18dd
Fixed test harnesses
zmanian ca275a2
adding FlagSecretStore to all key commands
poldsam 4283079
adding FlagSecretStore to all key commands
poldsam 3fb144a
fixing a typo in FlagSecretStore
poldsam 4511c5f
adding conditional for FlagSecretStore value; if set to false use new…
poldsam 9186212
Fixing testing errors for new keyring keybase
poldsam 66ba136
Fixing update_test to run only on legacy secret store, test irrelevan…
poldsam cbe6b34
Merge commit
poldsam 54ee067
Expected fix for the Import issue
zmanian 73f0188
Merge branch 'kristi/keyringKeybase' of github.com:Proof-Of-Audit/cos…
poldsam 2ab5885
Fixing migrate to point to the same keyring service
poldsam 5b5f483
Allowing signing for legacy key store
poldsam 8155784
adding migrate command to the changelog
poldsam 14053ee
deleting testing data after test finishes
poldsam 4ae6295
Updating migrate command in the changelog
poldsam 374b636
Don't ask for password when using keyring secret store
poldsam 02c146a
Detect if running on server
poldsam 41706eb
Add a print statement
poldsam c5fde86
Print backends
poldsam 395d008
Fix for backend detection
poldsam 9f6c0fb
update test password
poldsam e02969d
enter password twice
poldsam 2a56062
Productionizes the prompt using keyring file backend to be much more …
zmanian 669fa30
add some error handling
zmanian fb6c357
Print Bcrypt errors
zmanian e92e489
Fix the salt length
zmanian 878145f
Switch to random salt
zmanian 528df97
Switch to using the cobra provided input for getinng the keyring pass…
zmanian 17067ee
Fix tests so they compile
zmanian f6d5ff4
Hopefully fix add test
poldsam f8b78ae
Improve the delete command for servers
poldsam a224259
Delete_tests improvements
poldsam 04589a6
Another passphrase input
poldsam f379cfc
improving export_test
poldsam a7344d8
Fixing migrate_test
poldsam ce6806b
Massive refactor to pipe input through to the Keybase to handle the f…
zmanian f8867e4
Fixed for the add_test
poldsam dfef9ba
Fixing delete_test file
poldsam 010c4ec
Fixing add_test
poldsam 253f8ed
Fixing add file to pass password when using keyring to default storin…
poldsam 9539583
Fixing export_test
poldsam c21bd0c
Fixing export_test
poldsam 8b900c3
Fixing export_test
poldsam d49c4a0
Fixing export_tests
poldsam 9e2aa00
Add a debug print line
poldsam 17f023c
Switch buffer was passed to keybase for Add
poldsam 96b4b94
Switch the buffer we use in delete
poldsam 75e1acf
Fix test input
poldsam c182e14
Add mock input
poldsam bef4778
Switch the command buffer
poldsam 7c497d8
Fix passphase setting for import test
poldsam c474bef
Fixing list_tests
poldsam 2e8e881
Put the MockIn inside the loop
poldsam d1a013c
Count failures when using the file backend and eventually error
poldsam 7a78786
Fixing migrate_test
poldsam e66b8ce
Handle input buffer correctly
poldsam c6b537b
Fixing show_test
poldsam e98f309
Fixing show_test
poldsam 9f47a91
Fixing update_test
poldsam 4069283
Fixes for multiple password entries are needed
poldsam 6e6f1a3
Adding InBuf reader to show_test
poldsam effd2dd
Adding InBuf reader to tests
poldsam f3de484
Build deps update
poldsam 0b7ecd9
Kristi/keyring keybase (#1)
poldsam e8cf6c9
Try to cache passwords in the keyring so that they don't have to ente…
zmanian 9c4cf7e
Merge pull request #3 from Proof-Of-Audit/zaki/CachedPasswords
zmanian 09cc23f
Fixing error checking
poldsam 507cdcf
Removing unnecessary print statements
poldsam 2717800
Fixing fnt Print to redirect to stderr
poldsam c2338a7
Merge commit
poldsam 5207c7b
Deleting keys data
poldsam af7dece
Merge branch 'master' of github.com:cosmos/cosmos-sdk into kristi/key…
poldsam 8f66659
Removing unnecessary println statement
poldsam cfb4dd3
Removing println statement, moving this to Stderr
poldsam 9f73d8f
Merge branch 'master' of github.com:cosmos/cosmos-sdk into kristi/key…
poldsam 52a0bd9
Fixing package import error in list.go
poldsam 4ab875b
Merge branch 'master' of github.com:cosmos/cosmos-sdk into kristi/key…
poldsam d0f676e
Apply suggestions from code review
poldsam a9c3573
Merge branch 'kristi/keyringKeybase2' of github.com:Proof-Of-Audit/co…
poldsam e4417a1
Resolved comments from code review
poldsam 1cea42c
Merge commit
poldsam 777bbb0
Fix for build error
poldsam 7e348ae
Fixing print statement
poldsam 096f56c
Merge commit
poldsam bfc3b55
Refactor Clicontext constructor to better fit the builder pattern
poldsam acf6b17
updating changelog with Unreleased entry
poldsam 803d2eb
Fixing error handling and typos
poldsam 788f762
Fixing update_test
poldsam 2e74282
Fixing migrate_test
poldsam 54d2326
fixing conflicts
poldsam bbc3ea2
fixing conflicting changes
poldsam 9065a01
fixing make build error
poldsam f7c39a9
Fixing print errorrs
poldsam d83f189
removing keys
poldsam cda535e
Fixing tupos and errors
poldsam 553ef29
Fixing gobot typeSwitch error
poldsam cbb43ab
Update crypto/keys/keybase_keyring.go
poldsam c408e67
Update x/nft/client/cli/tx.go
poldsam 27fa3eb
Fixing gobot errors
poldsam d59bfd7
Fixing gobot errors
poldsam 3e1a2f3
Merge branch 'kristi/keyringKeybase2' of github.com:Proof-Of-Audit/co…
poldsam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,4 @@ dependency-graph.png | |
*.aux | ||
*.out | ||
*.synctex.gz | ||
.clog.yml | ||
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package context | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
"fmt" | ||
"io" | ||
|
@@ -36,6 +37,7 @@ type CLIContext struct { | |
Client rpcclient.Client | ||
Keybase cryptokeys.Keybase | ||
Output io.Writer | ||
Input io.Reader | ||
OutputFormat string | ||
Height int64 | ||
NodeURI string | ||
|
@@ -51,22 +53,17 @@ type CLIContext struct { | |
FromName string | ||
Indent bool | ||
SkipConfirm bool | ||
SecretStore bool | ||
} | ||
|
||
// NewCLIContextWithFrom returns a new initialized CLIContext with parameters from the | ||
// command line using Viper. It takes a key name or address and populates the FromName and | ||
// FromAddress field accordingly. | ||
func NewCLIContextWithFrom(from string) CLIContext { | ||
func NewCLIContext() CLIContext { | ||
var nodeURI string | ||
var rpc rpcclient.Client | ||
|
||
genOnly := viper.GetBool(flags.FlagGenerateOnly) | ||
fromAddress, fromName, err := GetFromFields(from, genOnly) | ||
alessio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
fmt.Printf("failed to get from fields: %v", err) | ||
os.Exit(1) | ||
} | ||
|
||
if !genOnly { | ||
nodeURI = viper.GetString(flags.FlagNode) | ||
if nodeURI != "" { | ||
|
@@ -80,7 +77,7 @@ func NewCLIContextWithFrom(from string) CLIContext { | |
verifierHome = viper.GetString(flags.FlagHome) | ||
} | ||
|
||
return CLIContext{ | ||
return CLIContext{ //assign value to new boolean var based on parsing the flag | ||
Client: rpc, | ||
Output: os.Stdout, | ||
NodeURI: nodeURI, | ||
|
@@ -93,17 +90,12 @@ func NewCLIContextWithFrom(from string) CLIContext { | |
Verifier: verifier, | ||
Simulate: viper.GetBool(flags.FlagDryRun), | ||
GenerateOnly: genOnly, | ||
FromAddress: fromAddress, | ||
FromName: fromName, | ||
Indent: viper.GetBool(flags.FlagIndentResponse), | ||
SkipConfirm: viper.GetBool(flags.FlagSkipConfirmation), | ||
SecretStore: viper.GetBool(flags.FlagLegacy), | ||
} | ||
} | ||
|
||
// NewCLIContext returns a new initialized CLIContext with parameters from the | ||
// command line using Viper. | ||
func NewCLIContext() CLIContext { return NewCLIContextWithFrom(viper.GetString(flags.FlagFrom)) } | ||
|
||
func createVerifier() tmlite.Verifier { | ||
trustNodeDefined := viper.IsSet(flags.FlagTrustNode) | ||
if !trustNodeDefined { | ||
|
@@ -238,6 +230,29 @@ func (ctx CLIContext) WithBroadcastMode(mode string) CLIContext { | |
return ctx | ||
} | ||
|
||
// WithInput returns a copy of the context with an updated input. | ||
func (ctx CLIContext) WithInput(input io.Reader) CLIContext { | ||
ctx.Input = bufio.NewReader(input) | ||
return ctx | ||
|
||
} | ||
|
||
// WithSecretStore returns a copy of the context with an updated SecretStore flag. | ||
func (ctx CLIContext) WithSecretStore() CLIContext { | ||
ctx.SecretStore = viper.GetBool(flags.FlagLegacy) | ||
|
||
if ctx.SecretStore { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change to |
||
var err error | ||
ctx.Keybase, err = keys.NewKeyBaseFromHomeFlag() | ||
if err != nil { | ||
panic(err) | ||
} | ||
} else { | ||
ctx.Keybase = keys.NewKeyringKeybase(ctx.Input) //if flag is set, add flag to struct, then boolean variable. | ||
} | ||
return ctx | ||
} | ||
|
||
// PrintOutput prints output while respecting output and indent flags | ||
// NOTE: pass in marshalled structs that have been unmarshaled | ||
// because this function will panic on marshaling errors | ||
|
@@ -264,14 +279,32 @@ func (ctx CLIContext) PrintOutput(toPrint fmt.Stringer) (err error) { | |
return | ||
} | ||
|
||
// WithFromFields returns a copy of the context with an updated FromName and FromAddres flag. | ||
func (ctx CLIContext) WithFromFields() CLIContext { | ||
from := viper.GetString(flags.FlagFrom) | ||
|
||
fromAddress, fromName, err := GetFromFields(from, ctx.GenerateOnly, ctx.Input) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
ctx.FromAddress = fromAddress | ||
ctx.FromName = fromName | ||
return ctx | ||
|
||
} | ||
|
||
// GetFromFields returns a from account address and Keybase name given either | ||
// an address or key name. If genOnly is true, only a valid Bech32 cosmos | ||
// address is returned. | ||
func GetFromFields(from string, genOnly bool) (sdk.AccAddress, string, error) { | ||
func GetFromFields(from string, genOnly bool, input io.Reader) (sdk.AccAddress, string, error) { | ||
if from == "" { | ||
return nil, "", nil | ||
} | ||
|
||
legacySecretStore := viper.GetBool(flags.FlagLegacy) | ||
|
||
if genOnly { | ||
addr, err := sdk.AccAddressFromBech32(from) | ||
if err != nil { | ||
|
@@ -281,11 +314,16 @@ func GetFromFields(from string, genOnly bool) (sdk.AccAddress, string, error) { | |
return addr, "", nil | ||
} | ||
|
||
keybase, err := keys.NewKeyBaseFromHomeFlag() | ||
if err != nil { | ||
return nil, "", err | ||
var keybase cryptokeys.Keybase | ||
if legacySecretStore { | ||
var err error | ||
keybase, err = keys.NewKeyBaseFromHomeFlag() | ||
if err != nil { | ||
return nil, "", err | ||
} | ||
} else { | ||
keybase = keys.NewKeyringKeybase(input) //if flag is set, add flag to struct, then boolean variable. | ||
} | ||
|
||
var info cryptokeys.Info | ||
if addr, err := sdk.AccAddressFromBech32(from); err == nil { | ||
info, err = keybase.GetByAddress(addr) | ||
|
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 |
---|---|---|
|
@@ -72,6 +72,7 @@ the flag --nosort is set. | |
cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation") | ||
cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation") | ||
cmd.Flags().Bool(flags.FlagIndentResponse, false, "Add indent to JSON response") | ||
cmd.Flags().Bool(flags.FlagLegacy, false, "Use legacy secret store") | ||
return cmd | ||
} | ||
|
||
|
@@ -101,11 +102,15 @@ func runAddCmd(cmd *cobra.Command, args []string) error { | |
kb = keys.NewInMemory() | ||
encryptPassword = DefaultKeyPass | ||
} else { | ||
kb, err = NewKeyBaseFromHomeFlag() | ||
if err != nil { | ||
return err | ||
if viper.GetBool(flags.FlagLegacy) { | ||
cmd.PrintErrf("IMPORTANT: using deprecated secret store. This will be removed in a future release.") | ||
kb, err = NewKeyBaseFromHomeFlag() | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
kb = NewKeyringKeybase(inBuf) | ||
} | ||
|
||
_, err = kb.Get(name) | ||
if err == nil { | ||
// account exists, ask for user confirmation | ||
|
@@ -152,13 +157,15 @@ func runAddCmd(cmd *cobra.Command, args []string) error { | |
} | ||
|
||
// ask for a password when generating a local key | ||
if viper.GetString(FlagPublicKey) == "" && !viper.GetBool(flags.FlagUseLedger) { | ||
if viper.GetString(FlagPublicKey) == "" && !viper.GetBool(flags.FlagUseLedger) && viper.GetBool(flags.FlagLegacy) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. split line |
||
encryptPassword, err = input.GetCheckPassword( | ||
"Enter a passphrase to encrypt your key to disk:", | ||
"Repeat the passphrase:", inBuf) | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
encryptPassword = DefaultKeyPass | ||
} | ||
} | ||
|
||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo + merge master 👍