Feature request
Description
If 2FA is enabled for a user account, a valid TOTP token is required. ivpn login currently only supports passing such a token interactively.
I would like to pass a token along the account ID non-interactivley. This is especially useful for scripting etc.
Implementation Details
As far as I can tell with my limited knowledge, doLogin(...) in cli/commands/account.go is the code to look for.
After session creation, if the condition resp.APIStatus == types.The2FARequired is true, it just prints to STDOUT and reads the token from STDIN, then retries creating the session with the provided token.
Describe the solution you'd like
Primarliy, a new optional flag -totp <string> could be added that accepts such a token and
- uses the token if 2FA is required,
- or drops it silently if not.
In addition, it should be checked whether os.STDIN is a TTY (fe. via cross-platform mattn/go-isatty).
If os.STDIN is not and the user also did not pass -totp, the CLI should exit with an error and only prompt interactively if os.STDIN is a TTY and the user did not pass -totp.
Describe alternatives you've considered
none
Feature request
Description
If 2FA is enabled for a user account, a valid TOTP token is required.
ivpn logincurrently only supports passing such a token interactively.I would like to pass a token along the account ID non-interactivley. This is especially useful for scripting etc.
Implementation Details
As far as I can tell with my limited knowledge,
doLogin(...)incli/commands/account.gois the code to look for.After session creation, if the condition
resp.APIStatus == types.The2FARequiredis true, it just prints to STDOUT and reads the token from STDIN, then retries creating the session with the provided token.Describe the solution you'd like
Primarliy, a new optional flag
-totp <string>could be added that accepts such a token andIn addition, it should be checked whether
os.STDINis a TTY (fe. via cross-platformmattn/go-isatty).If
os.STDINis not and the user also did not pass-totp, the CLI should exit with an error and only prompt interactively ifos.STDINis a TTY and the user did not pass-totp.Describe alternatives you've considered
none