@ -157,18 +157,18 @@ Whenever you make an edit to the rule file, you need to use attestation to tell
Clef that the file is ' safe ' to execute . ` ,
}
add CredentialCommand = cli . Command {
Action : utils . MigrateFlags ( add Credential) ,
Name : "add pw" ,
set CredentialCommand = cli . Command {
Action : utils . MigrateFlags ( set Credential) ,
Name : "set pw" ,
Usage : "Store a credential for a keystore file" ,
ArgsUsage : "<address> <password> " ,
ArgsUsage : "<address>" ,
Flags : [ ] cli . Flag {
logLevelFlag ,
configdirFlag ,
signerSecretFlag ,
} ,
Description : `
The add pw command stores a password for a given address ( keyfile ) . If you invoke it with only one parameter , it will
The set pw command stores a password for a given address ( keyfile ) . If you enter a blank passphrase , it will
remove any stored credential for that address ( keyfile )
` ,
}
@ -200,7 +200,7 @@ func init() {
advancedMode ,
}
app . Action = signer
app . Commands = [ ] cli . Command { initCommand , attestCommand , add CredentialCommand}
app . Commands = [ ] cli . Command { initCommand , attestCommand , set CredentialCommand}
}
func main ( ) {
@ -293,14 +293,17 @@ func attestFile(ctx *cli.Context) error {
return nil
}
func add Credential( ctx * cli . Context ) error {
func set Credential( ctx * cli . Context ) error {
if len ( ctx . Args ( ) ) < 1 {
utils . Fatalf ( "This command requires at leaste one argument." )
utils . Fatalf ( "This command requires an address to be passed as an argument." )
}
if err := initialize ( ctx ) ; err != nil {
return err
}
address := ctx . Args ( ) . First ( )
password := getPassPhrase ( "Enter a passphrase to store with this address." , true )
stretchedKey , err := readMasterKey ( ctx , nil )
if err != nil {
utils . Fatalf ( err . Error ( ) )
@ -311,13 +314,8 @@ func addCredential(ctx *cli.Context) error {
// Initialize the encrypted storages
pwStorage := storage . NewAESEncryptedStorage ( filepath . Join ( vaultLocation , "credentials.json" ) , pwkey )
key := ctx . Args ( ) . First ( )
value := ""
if len ( ctx . Args ( ) ) > 1 {
value = ctx . Args ( ) . Get ( 1 )
}
pwStorage . Put ( key , value )
log . Info ( "Credential store updated" , "key" , key )
pwStorage . Put ( address , password )
log . Info ( "Credential store updated" , "key" , address )
return nil
}