Skip to content

Commit 3094f0c

Browse files
committed
[cli] Support interactive aquisition of ssh private key passphrase
1 parent 7b06ef0 commit 3094f0c

File tree

4 files changed

+65
-18
lines changed

4 files changed

+65
-18
lines changed

cli/README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,27 +86,42 @@ export ANTI_WALLET_FILE=wallet.json
8686

8787
Optionally you can provide a passphrase to encrypt the mnemonic phrase in the wallet file:
8888

89+
> Setting a passphrase is highly recommended to protect your wallet
90+
91+
A less secure way to provide the passphrase is to set the `ANTI_WALLET_PASSPHRASE` environment variable:
92+
8993
```bash
9094
read -s -p "Enter your wallet passphrase: " ANTI_WALLET_PASSPHRASE
9195
export ANTI_WALLET_PASSPHRASE
9296
```
93-
9497
You can create a wallet file with the `anti wallet create` command:
9598

9699
```bash
97100
antij wallet create
98101
```
99102

100-
It will fail to re-create the file if it already exists. You can review this wallet info anytime with
103+
A more secure way is to let the CLI prompt you for the passphrase when needed.
104+
105+
```bash
106+
antij wallet create --ask-passphrase
107+
```
108+
109+
If you set the `ANTI_INTERACTIVE_PASSWORD` environment variable to any value, the CLI will prompt you for the passphrase every time it needs it.
110+
111+
```bash
112+
export ANTI_INTERACTIVE_PASSWORD=1
113+
```
114+
115+
You can review this wallet info anytime with
101116

102117
```bash
103118
antij wallet info
104119
```
105120

106-
Remember to read your wallet passphrase into the `ANTI_WALLET_PASSPHRASE` environment variable before running any command that requires the wallet.
121+
> Store a copy of your encrypted/plaintext wallet file in a password manager. Think twice before storing a plaintext wallet file. Store your passphrase in a password manager too. ATM we do not support hardware wallets like Ledger or Trezor.
107122
108123
> Fund your wallet with some tAda tokens on preprod, for example using the [Cardano Testnet Faucet](https://docs.cardano.org/cardano-testnets/tools/faucet/).
109-
>
124+
110125

111126
### Antithesis token
112127

cli/docs/requester-role.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,23 @@ Before proceding be careful to set the necessary signing assets in your environm
111111
112112
Path to the SSH private key file
113113
env: ANTI_SSH_FILE FILEPATH
114+
```
115+
116+
As with the wallet passphrase you can set the password in the environment variable
114117
115-
Password to the decrypt the SSH private key
116-
env: ANTI_SSH_PASSWORD STRING
118+
```bash
119+
read -s -p "Enter password to decrypt the SSH private key: " ANTI_INTERACTIVE_PASSWORD
120+
export ANTI_INTERACTIVE_PASSWORD
117121
```
118122
119-
The file at ANTI_SSH_FILE FILEPATH is the encrypted ssh private key matching the user registration.
123+
Or better paste it from a password manager each time you need it using the 'ask-password' option
124+
125+
Or set the `ANTI_INTERACTIVE_PASSWORD` environment variable to any value.
126+
127+
> The file at ANTI_SSH_FILE path has to be the encrypted ssh private key matching the user registration [see above](#registering-a-user-public-key).
120128
121129
To request a test-run, you can use the `antij requester create-test` command.
130+
122131
```bash
123132
antij requester create-test --platform github --username alice --repository yourorg/yourrepo --directory ./path/to/your/test/directory --commit your_commit_hash --try 1 --duration 2
124133
```
@@ -132,5 +141,3 @@ You can check the status of your test-run requests with the `antij facts test-ru
132141
```bash
133142
antij facts test-run pending
134143
```
135-
136-

cli/src/Core/Types/Mnemonics/Options.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module Core.Types.Mnemonics.Options
22
( mnemonicsParser
33
, walletPassphraseCommon
44
, walletFileOption
5+
, queryConsole
56
) where
67

78
import Control.Exception (try)
@@ -12,6 +13,7 @@ import Data.Aeson
1213
)
1314
import Data.Aeson qualified as Aeson
1415
import Data.ByteString.Lazy qualified as BL
16+
import Data.Functor (($>))
1517
import Data.Text (Text)
1618
import Data.Text qualified as T
1719
import OptEnvConf
@@ -30,7 +32,6 @@ import OptEnvConf
3032
, setting
3133
, short
3234
, str
33-
, switch
3435
, withConfig
3536
)
3637
import System.Console.Haskeline
@@ -56,8 +57,12 @@ walletPassphraseCommon =
5657
mapIO id
5758
$ setting
5859
[ help "Prompt for the passphrase for the encrypted mnemonics"
59-
, long "interactive-wallet-passphrase"
60-
, switch $ queryConsole "Enter passphrase for encrypted mnemonics"
60+
, env "ANTI_INTERACTIVE_PASSWORD"
61+
, metavar "NONE"
62+
, long "ask-passphrase"
63+
, option
64+
, reader
65+
$ str @String $> queryConsole "Enter passphrase for encrypted mnemonics"
6166
]
6267
<|> setting
6368
[ env "ANTI_WALLET_PASSPHRASE"

cli/src/User/Requester/Options.hs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import Core.Options
1919
, usernameOption
2020
, walletOption
2121
)
22+
import Core.Types.Mnemonics.Options (queryConsole)
2223
import Core.Types.Tx (TxHash, WithTxHash)
24+
import Data.Functor (($>))
25+
import Data.Text qualified as T
2326
import Lib.Box (Box (..))
2427
import Lib.SSH.Private (SSHClient (..))
2528
import OptEnvConf
@@ -28,10 +31,14 @@ import OptEnvConf
2831
, commands
2932
, env
3033
, help
34+
, long
35+
, mapIO
3136
, metavar
37+
, option
3238
, reader
3339
, setting
3440
, str
41+
, (<|>)
3542
)
3643
import Oracle.Validate.Requests.RegisterRole
3744
( RegisterRoleFailure
@@ -150,12 +157,25 @@ keyFileOption =
150157

151158
keyPasswordOption :: Parser String
152159
keyPasswordOption =
153-
setting
154-
[ env "ANTI_SSH_PASSWORD"
155-
, help "Password to the decrypt the SSH private key"
156-
, metavar "STRING"
157-
, reader str
158-
]
160+
mapIO id
161+
$ setting
162+
[ help "Prompt for the password to decrypt the SSH private key"
163+
, env "ANTI_INTERACTIVE_PASSWORD"
164+
, metavar "NONE"
165+
, long "ask-password"
166+
, option
167+
, reader
168+
$ str @String
169+
$> ( T.unpack
170+
<$> queryConsole "Enter password for SSH private key"
171+
)
172+
]
173+
<|> setting
174+
[ env "ANTI_SSH_PASSWORD"
175+
, help "Password to the decrypt the SSH private key"
176+
, metavar "STRING"
177+
, reader (pure <$> str)
178+
]
159179

160180
requestTestOptions
161181
:: Parser

0 commit comments

Comments
 (0)