Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b00191

Browse files
authored
fix: don't store token when certificates are configured (#192)
This was a regression for the custom flows that required authentication via certificates, the http client and the coder cli were properly initialized but afterward the token was still required for storing. Note: the issue was hard to catch early on because the official coder cli is not supporting auth. via certificates.
1 parent f056813 commit 6b00191

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixed
6+
7+
- token is no longer required when authentication is done via certificates
8+
59
## 0.6.4 - 2025-09-03
610

711
### Added

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=0.6.4
1+
version=0.6.5
22
group=com.coder.toolbox
33
name=coder-toolbox

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ class CoderRemoteProvider(
242242
* Also called as part of our own logout.
243243
*/
244244
override fun close() {
245-
pollJob?.cancel()
245+
pollJob?.let {
246+
it.cancel()
247+
context.logger.info("Cancelled workspace poll job ${pollJob.toString()}")
248+
}
246249
client?.close()
247250
lastEnvironments.clear()
248251
environments.value = LoadableState.Value(emptyList())
@@ -327,6 +330,7 @@ class CoderRemoteProvider(
327330

328331
environments.showLoadingMessage()
329332
pollJob = poll(restClient, cli)
333+
context.logger.info("Workspace poll job with name ${pollJob.toString()} was created while handling URI $uri")
330334
isInitialized.waitForTrue()
331335
}
332336
} catch (ex: Exception) {
@@ -396,19 +400,23 @@ class CoderRemoteProvider(
396400
private fun onConnect(client: CoderRestClient, cli: CoderCLIManager) {
397401
// Store the URL and token for use next time.
398402
context.secrets.lastDeploymentURL = client.url.toString()
399-
context.secrets.lastToken = client.token ?: ""
400-
context.secrets.storeTokenFor(client.url, context.secrets.lastToken)
401-
context.logger.info("Deployment URL and token were stored and will be available for automatic connection")
403+
if (context.settingsStore.requireTokenAuth) {
404+
context.secrets.lastToken = client.token ?: ""
405+
context.secrets.storeTokenFor(client.url, context.secrets.lastToken)
406+
context.logger.info("Deployment URL and token were stored and will be available for automatic connection")
407+
} else {
408+
context.logger.info("Deployment URL was stored and will be available for automatic connection")
409+
}
402410
this.client = client
403411
pollJob?.let {
404412
it.cancel()
405-
context.logger.info("Workspace poll job with reference ${pollJob} was canceled")
413+
context.logger.info("Cancelled workspace poll job ${pollJob.toString()} in order to start a new one")
406414
}
407415
environments.showLoadingMessage()
408416
coderHeaderPage.setTitle(context.i18n.pnotr(client.url.toString()))
409417
context.logger.info("Displaying ${client.url} in the UI")
410418
pollJob = poll(client, cli)
411-
context.logger.info("Workspace poll job created with reference $pollJob")
419+
context.logger.info("Workspace poll job with name ${pollJob.toString()} was created")
412420
}
413421

414422
private fun MutableStateFlow<LoadableState<List<CoderRemoteEnvironment>>>.showLoadingMessage() {

0 commit comments

Comments
 (0)