mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 23:27:14 +00:00
prevent auto saving passphrase to disk
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/manifoldco/promptui"
|
"github.com/manifoldco/promptui"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
@@ -33,23 +33,19 @@ func SetValueInKeyring(key, value string) error {
|
|||||||
|
|
||||||
if configFile.VaultBackendPassphrase == "" {
|
if configFile.VaultBackendPassphrase == "" {
|
||||||
passphrasePrompt := promptui.Prompt{
|
passphrasePrompt := promptui.Prompt{
|
||||||
Label: "Enter a passphrase to protect your local secret backups & login access token",
|
Label: "Enter a passphrase to encrypt sensitive CLI data at rest",
|
||||||
}
|
}
|
||||||
passphrase, err := passphrasePrompt.Run()
|
passphrase, err := passphrasePrompt.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedPassphrase := base64.StdEncoding.EncodeToString([]byte(passphrase))
|
|
||||||
configFile.VaultBackendPassphrase = encodedPassphrase
|
|
||||||
configFile.VaultBackendType = VAULT_BACKEND_FILE_MODE
|
configFile.VaultBackendType = VAULT_BACKEND_FILE_MODE
|
||||||
err = WriteConfigFile(&configFile)
|
err = WriteConfigFile(&configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// We call this function at last to trigger the environment variable to be set
|
os.Setenv("INFISICAL_VAULT_FILE_PASSPHRASE", passphrase)
|
||||||
GetConfigFile()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = keyring.Set(VAULT_BACKEND_FILE_MODE, MAIN_KEYRING_SERVICE, key, value)
|
err = keyring.Set(VAULT_BACKEND_FILE_MODE, MAIN_KEYRING_SERVICE, key, value)
|
||||||
|
|||||||
Reference in New Issue
Block a user