Skip to content

Conversation

fioan89
Copy link
Collaborator

@fioan89 fioan89 commented Sep 25, 2025

Context: Toolbox can store key/value pairs in two places:

  • a settings store which is backed by a clear text json file per each plugin
  • native keystore for sensitive data

At the same time some of Coder's clients (ex: Netflix) would like to deploy at scale preconfigured settings for Toolbox. Most of the needed settings are part of json backed store except the last used URL.

This PR reworks the code around the last used URL/token and moves the URL in the json backed store, making it easy to configure. At the same time we still support the pair stored in the native keystore for backward compatibility reasons.

Context: Toolbox can store key/value pairs in two places:
- a settings store which is backed by a clear text json file per each plugin
- native keystore for sensitive data

At the same time some of Coder's clients (ex: Netflix) would like to deploy at
scale preconfigured settings for Toolbox. Most of the needed settings are part of
json backed store except the last used URL.

This PR reworks the code around the last used URL/token and moves the URL in the
json backed store, making it easy to configure. At the same time we still support
the pair stored in the native keystore for backward compatibility reasons.
After a successful connection to a deployment URL we used
to save the same token associated with two keys:
- last-token
- and associated with the last url

But it does not make sense, once we have to URL we can easily resolve the token
associated with the URL. In other words this commit removes the ability to read/save
a token associated with `last-token` key.
URL stored in the native OS secrets store is now superseded by
the URL stored in the JSON backed settings store.
With a takIf/let pattern. Theoretically you can have two threads
racing - one changing the value of lastDeploymentURL and another
\one reading. In our code that should be pretty much impossible.
But the compiler can't be sure of that so it throws and error.
@fioan89 fioan89 merged commit 94b329f into main Sep 27, 2025
6 checks passed
@fioan89 fioan89 deleted the store-last-used-url-in-settings branch September 27, 2025 08:48
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