Skip to content

Commit 5399431

Browse files
committed
chore: last token should be stored only per URL
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.
1 parent 3ac20d4 commit 5399431

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ class CoderRemoteProvider(
406406
// Store the URL and token for use next time.
407407
context.settingsStore.updateLastUsedUrl(client.url)
408408
if (context.settingsStore.requireTokenAuth) {
409-
context.secrets.lastToken = client.token ?: ""
410409
context.secrets.storeTokenFor(client.url, client.token ?: "")
411410
context.logger.info("Deployment URL and token were stored and will be available for automatic connection")
412411
} else {

src/main/kotlin/com/coder/toolbox/store/CoderSecretsStore.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,7 @@ import java.net.URL
88
* Provides Coder secrets backed by the secrets store service.
99
*/
1010
class CoderSecretsStore(private val store: PluginSecretStore) {
11-
private fun get(key: String): String = store[key] ?: ""
12-
13-
private fun set(key: String, value: String) {
14-
if (value.isBlank()) {
15-
store.clear(key)
16-
} else {
17-
store[key] = value
18-
}
19-
}
20-
21-
val lastDeploymentURL: String
22-
get() = get("last-deployment-url")
23-
var lastToken: String
24-
get() = get("last-token")
25-
set(value) = set("last-token", value)
11+
val lastDeploymentURL: String = store["last-deployment-url"] ?: ""
2612

2713
fun tokenFor(url: URL): String? = store[url.host]
2814

0 commit comments

Comments
 (0)