oxidecomputer / oxide.rs

The Oxide Rust SDK and CLI
Mozilla Public License 2.0
38 stars 14 forks source link

Using `oxide auth logout` (without specifying the profile) should confirm default profile and/or check if that default still even exists #796

Open twinfees opened 2 months ago

twinfees commented 2 months ago

Component

What was the expected behaviour

If you have multiple profiles and run oxide auth logout without specifying the profile (i.e. oxide --profile oxide auth logout), the confirmation prompt should confirm your default profile and/or ask you which profile you want to remove, with a list of your existing profiles that are authenticated.

Additionally, if the default profile no longer exists, oxide auth logout should know about that. For example:

With only the one profile:

$ oxide auth status                                                                                                                                          
Profile "oxide2" (https://oxide.sys.blah3.blah-preview.com) status: Authenticated

If I run the command without the --profile flag, it still tells me that its removed the auth for a profile that no longer exists:

$ oxide auth logout
Confirm authentication information deletion: yes
Removed authentication information for profile "oxide"

What is the current behaviour and what actions did you take to get there

With four profiles set (note that three are to the same silo - also filed as a possible bug):

$ oxide auth status 
Profile "oxide" (https://oxide.sys.blah2.blahblah.com) status: Authenticated
Profile "oxide2" (https://oxide.sys.blah3.blah-preview.com) status: Authenticated
Profile "oxide3" (https://oxide.sys.blah3.blah-preview.com) status: Authenticated
Profile "oxide4" (https://oxide.sys.blah3.blah-preview.com) status: Authenticated

If I forget to include the profile and just run oxide auth logout, I get the following:

$ oxide auth logout 
Confirm authentication information deletion: [y/n]

Confirming Yes removes the default profile as expected; but one might forget which profile is their default.

CLI or SDK version

0.6.2+20240710.0

Operating system

Sonoma 14.3

Anything else you would like to add?

No response

twinfees commented 2 months ago

Just realized the config.toml file exists, which contains the default profile info. I can set my default to anything, and it will tell me that it's removed the auth for that, i.e.:

$ oxide auth logout                                                                                                                              
Confirm authentication information deletion: yes
Removed authentication information for profile "fake-profile"