Skip to content

Non-interactive Login with TOTP tokens #539

Description

@lsg551

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

  1. uses the token if 2FA is required,
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions