Skip to content

fix: remember token when switching deployments #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025

Conversation

fioan89
Copy link
Collaborator

@fioan89 fioan89 commented May 22, 2025

If we log in on deployment 1, then log out and login to deployment 2 and then in the same session we try to log in back to deployment 1, the token is no longer valid. The plugin will associate with deployment 1 the token from the second deployment.

There is an overly complicated block of code inherited from Gateway plugin with multiple fallback sequences for both the deployment url and token from multiple sources (secrets store, data dir config, env, etc...). This fix simplifies the approach, we only store the url and the token in the secrets store, the token is always associated to a hostname. If there is no previous URL to remember (like the first time login) we default to https://dev.coder.com/ and empty token.

If we log in on deployment 1, then log out and login to deployment 2 and then in the same session
we try to log in back to deployment 1, the token is no longer valid. The plugin will associate with
deployment 1 the token from the second deployment.

There is an overly complicated block of code inherited from Gateway plugin with multiple fallback sequences
for both the deployment url and token from multiple sources (secrets store, data dir config, env, etc...).
This fix simplifies the approach, we only store the url and the token in the secrets store, the token is
always associated to a hostname. If there is no previous URL to remember (like the first time login) we
default to https://dev.coder.com/ and empty token.
@fioan89 fioan89 requested review from matifali and f0ssel May 22, 2025 22:25
fioan89 added 3 commits May 23, 2025 21:42
On top of that the shared auth context was reset each time the TBX window was hided and then made
visible again. The auth context is now a singleton object shared between the wizard steps
@fioan89 fioan89 marked this pull request as ready for review May 23, 2025 21:42
@fioan89
Copy link
Collaborator Author

fioan89 commented May 23, 2025

@fioan89 fioan89 requested a review from matifali May 23, 2025 21:50
@fioan89 fioan89 merged commit 208225b into main May 26, 2025
5 checks passed
@fioan89 fioan89 deleted the remember-token-when-switching-deployments branch May 26, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants