Skip to content

Commit 11245b6

Browse files
committed
impl: add new configurable option to disable CLI signature verification
These options are configurable from the Settings page there is no available shortcut on the main plugin page to discourage the quick disable of CLI verification
1 parent 0164c60 commit 11245b6

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

src/main/kotlin/com/coder/gateway/CoderSettingsConfigurable.kt

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ import com.intellij.openapi.components.service
88
import com.intellij.openapi.options.BoundConfigurable
99
import com.intellij.openapi.ui.DialogPanel
1010
import com.intellij.openapi.ui.ValidationInfo
11+
import com.intellij.ui.components.JBCheckBox
1112
import com.intellij.ui.components.JBTextField
1213
import com.intellij.ui.dsl.builder.AlignX
14+
import com.intellij.ui.dsl.builder.Cell
1315
import com.intellij.ui.dsl.builder.RowLayout
1416
import com.intellij.ui.dsl.builder.bindSelected
1517
import com.intellij.ui.dsl.builder.bindText
1618
import com.intellij.ui.dsl.builder.panel
19+
import com.intellij.ui.dsl.builder.selected
1720
import com.intellij.ui.layout.ValidationInfoBuilder
21+
import com.intellij.ui.layout.not
1822
import java.net.URL
1923
import java.nio.file.Path
2024

@@ -60,22 +64,27 @@ class CoderSettingsConfigurable : BoundConfigurable("Coder") {
6064
.bindText(state::binaryDirectory)
6165
.comment(CoderGatewayBundle.message("gateway.connector.settings.binary-destination.comment"))
6266
}.layout(RowLayout.PARENT_GRID)
63-
row {
64-
cell() // For alignment.
65-
checkBox(CoderGatewayBundle.message("gateway.connector.settings.enable-binary-directory-fallback.title"))
66-
.bindSelected(state::enableBinaryDirectoryFallback)
67-
.comment(
68-
CoderGatewayBundle.message("gateway.connector.settings.enable-binary-directory-fallback.comment"),
69-
)
70-
}.layout(RowLayout.PARENT_GRID)
71-
row {
72-
cell() // For alignment.
73-
checkBox(CoderGatewayBundle.message("gateway.connector.settings.fallback-on-coder-for-signatures.title"))
74-
.bindSelected(state::fallbackOnCoderForSignatures)
75-
.comment(
76-
CoderGatewayBundle.message("gateway.connector.settings.fallback-on-coder-for-signatures.comment"),
77-
)
78-
}.layout(RowLayout.PARENT_GRID)
67+
group {
68+
lateinit var signatureVerificationCheckBox: Cell<JBCheckBox>
69+
row {
70+
cell() // For alignment.
71+
signatureVerificationCheckBox =
72+
checkBox(CoderGatewayBundle.message("gateway.connector.settings.disable-signature-validation.title"))
73+
.bindSelected(state::disableSignatureVerification)
74+
.comment(
75+
CoderGatewayBundle.message("gateway.connector.settings.disable-signature-validation.comment"),
76+
)
77+
}.layout(RowLayout.PARENT_GRID)
78+
row {
79+
cell() // For alignment.
80+
checkBox(CoderGatewayBundle.message("gateway.connector.settings.fallback-on-coder-for-signatures.title"))
81+
.bindSelected(state::fallbackOnCoderForSignatures)
82+
.comment(
83+
CoderGatewayBundle.message("gateway.connector.settings.fallback-on-coder-for-signatures.comment"),
84+
)
85+
}.visibleIf(signatureVerificationCheckBox.selected.not())
86+
.layout(RowLayout.PARENT_GRID)
87+
}
7988
row(CoderGatewayBundle.message("gateway.connector.settings.header-command.title")) {
8089
textField().resizableColumn().align(AlignX.FILL)
8190
.bindText(state::headerCommand)
@@ -122,7 +131,10 @@ class CoderSettingsConfigurable : BoundConfigurable("Coder") {
122131
textArea().resizableColumn().align(AlignX.FILL)
123132
.bindText(state::sshConfigOptions)
124133
.comment(
125-
CoderGatewayBundle.message("gateway.connector.settings.ssh-config-options.comment", CODER_SSH_CONFIG_OPTIONS),
134+
CoderGatewayBundle.message(
135+
"gateway.connector.settings.ssh-config-options.comment",
136+
CODER_SSH_CONFIG_OPTIONS
137+
),
126138
)
127139
}.layout(RowLayout.PARENT_GRID)
128140
row(CoderGatewayBundle.message("gateway.connector.settings.setup-command.title")) {
@@ -162,7 +174,7 @@ class CoderSettingsConfigurable : BoundConfigurable("Coder") {
162174
.bindText(state::defaultIde)
163175
.comment(
164176
"The default IDE version to display in the IDE selection dropdown. " +
165-
"Example format: CL 2023.3.6 233.15619.8",
177+
"Example format: CL 2023.3.6 233.15619.8",
166178
)
167179
}
168180
row(CoderGatewayBundle.message("gateway.connector.settings.check-ide-updates.heading")) {

src/main/kotlin/com/coder/gateway/settings/CoderSettings.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ open class CoderSettingsState(
6565
open var enableBinaryDirectoryFallback: Boolean = false,
6666

6767
/**
68-
* Controls whether we fall back release.coder.com
68+
* Controls whether we verify the cli signature
69+
*/
70+
open var disableSignatureVerification: Boolean = false,
71+
72+
/**
73+
* Controls whether we fall back release.coder.com if signature validation is enabled
6974
*/
7075
open var fallbackOnCoderForSignatures: Boolean = false,
7176

@@ -160,6 +165,12 @@ open class CoderSettings(
160165
val enableBinaryDirectoryFallback: Boolean
161166
get() = state.enableBinaryDirectoryFallback
162167

168+
/**
169+
* Controls whether we verify the cli signature
170+
*/
171+
val disableSignatureVerification: Boolean
172+
get() = state.disableSignatureVerification
173+
163174
/**
164175
* Controls whether we fall back release.coder.com
165176
*/

src/main/resources/messages/CoderGatewayBundle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ gateway.connector.settings.enable-binary-directory-fallback.title=Fall back to d
7575
gateway.connector.settings.enable-binary-directory-fallback.comment=Checking this \
7676
box will allow the plugin to fall back to the data directory when the CLI \
7777
directory is not writable.
78-
78+
gateway.connector.settings.disable-signature-validation.title=Disable Coder CLI signature verification
79+
gateway.connector.settings.disable-signature-validation.comment=Useful if you run an unsigned fork for the binary
7980
gateway.connector.settings.fallback-on-coder-for-signatures.title=Fall back on releases.coder.com for signatures
8081
gateway.connector.settings.fallback-on-coder-for-signatures.comment=Verify binary signature using releases.coder.com when CLI signatures are not available from the deployment
81-
8282
gateway.connector.settings.header-command.title=Header command
8383
gateway.connector.settings.header-command.comment=An external command that \
8484
outputs additional HTTP headers added to all requests. The command must \

0 commit comments

Comments
 (0)