valohai / valohai-cli

:heavy_dollar_sign: Command line client for Valohai
MIT License
14 stars 8 forks source link

Smoother token login flow #310

Closed akx closed 6 months ago

akx commented 6 months ago

Instead of telling the user to run a command to log in with the token they generate, we ask for it interactively.

Fixes #307.

In lieu of a screenshot...

$ vh login --host https://valohai.local/

If you don't yet have an account, please create one at https://valohai.local/ first.

https://valohai.local/ - Username: 2faman
2faman on https://valohai.local/ - Password: [...]
Retrieving API token from https://valohai.local/...
======================================================================================
Oops!
The error code "has_2fa" indicates username + password authentication is not possible.
Use a login token instead:
 1. Log in on https://valohai.local/
 2. Visit https://valohai.local/auth/tokens/ to generate an authentication token
 3. Once you have an authentication token, paste it below and we'll try it out.
======================================================================================
Enter generated token: [...]
Verifying API token on https://valohai.local/...
šŸ˜„  Success! Logged in. Hey 2faman!
tarekoraby commented 6 months ago

I assume that valohai.local will be replaced by app.valohai.com in production. Is that correct? If so, should we care about on-prem installations (i.e., should we tell users that they might want to replace app.valohai.com with their own org url)?

dangquangdon commented 6 months ago

I assume that valohai.local will be replaced by app.valohai.com in production. Is that correct? If so, should we care about on-prem installations (i.e., should we tell users that they might want to replace app.valohai.com with their own org url)?

By default the CLI is pointing to app.valohai.com, but user can use --valohai-host to override it with whatever host they use. Iirc, it was also mentioned in the academy šŸ¤”

akx commented 6 months ago

Should we care about on-prem installations?

Yes, the messaging will use whichever host the user specifies (updated the "screenshot" to reflect that I actually pointed the CLI to my local install).