canonical / ubuntu-pro-client

Ubuntu Pro Client for offerings from Canonical
https://canonical-ubuntu-pro-client.readthedocs-hosted.com/en/latest/
GNU General Public License v3.0
52 stars 73 forks source link

Feature: accept token to `pro attach` via `getpass` #3165

Open orndorffgrant opened 3 months ago

orndorffgrant commented 3 months ago

Please describe the scenario where the new feature would be useful

pro attach $token isn't ideal because the token ends up in cmdline.

Describe the solution you'd like

Something like pro attach --token (flag name to be bikeshedded) would give a getpass prompt for the token.

Current behavior

There are several alternatives for attaching, but this would be the simplest method of attachment for someone who already copied their token from the website.

orndorffgrant commented 2 months ago

After talking with @cpaelzer we thought of a nicer UX for this feature.

Instead of having a new flag, this should be presented as an option with a plain pro attach.

So pro attach would kick-off two processes: magic-attach and getpass for the token. Then the user can choose which one to do (this is similar to the desktop and installer's approaches as well).

pro attach output will look something like this:

root@test:~# pro attach
Initiating attach operation...

Please sign in to your Ubuntu Pro account at this link:
https://ubuntu.com/pro/attach
And provide the following code: YR2NN0

Or if you already have your Ubuntu Pro token ready, enter it here: 

where the bottom prompt is a getpass prompt (so the token is not echoed to the terminal)

If the user enters the token, then the magic-attach process is cancelled (and the temporary user code is revoked).

If the user follows the magic attach instructions, then the getpass prompt is cancelled.