superfly / flyctl

Command line tools for fly.io services
https://fly.io
Apache License 2.0
1.43k stars 241 forks source link

Fly auth does not maintain authenticated login #1501

Open mrjonesbot opened 1 year ago

mrjonesbot commented 1 year ago

Please only report specific issues with flyctl behavior. Anything like a support request for your application should go to https://community.fly.io. More people watch that space and can help you faster!

Describe the bug Briefly, describe what broke and provide the following details:

Authenticating between two fly accounts, switching accounts with fly auth login does not hold persist authentication on the chosen account, switching silently between commands, triggering "No organization found" errors.

Described here as well: https://community.fly.io/t/fly-auth-does-not-maintain-authenticated-login/9128

Command output:

Screen Shot 2022-12-01 at 4 44 29 PM

ndarilek commented 1 year ago

Are you able to send a text-based (I.e. no screenshots) sequence of commands you ran to cause this?

I'm not able to replicate. I created a second account under a different email, signed out of my primary account, signed into the secondary, ran fly auth login, and fly apps list was empty under the second account. I then signed out of the secondary account and back into the primary, and got my usual fly apps list output.

But different commands may be using different codepaths, and I'd like to follow your exact steps to see if this is still an issue.

Thanks!

ndarilek commented 1 year ago

Closing for now, please re-open with more information and I'm happy to fix it. Thanks!

tvdfly commented 1 year ago

I've seen this before when switching between orgs. I was reliably seeing it for a while when I was switching between an org in my local graphql dev instance and the production api. I suspect that the fly agent is caching some state somewhere and rewriting it, but I don't have a reliable repro case at the moment. I'll update when I see it again!

tvdfly commented 1 year ago

Btw, the work around is: fly auth logout ; fly agent stop, then do whatever with the new auth/org/etc.

mrjonesbot commented 1 year ago

Thanks for the reply @ndarilek , sorry for the slow response.

In order to avoid this issue, I consolidated both organizations onto one account and have not experienced it since.

Since I no longer have two accounts, I won't reproduce, but if this should happen again in the future I'll provide a more detailed step by step.

@tvdfly has some interesting insight here, I suspect something like this is happening.