Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add options to support client tls#128

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
code-asher merged 1 commit intocoder:mainfromcoryb:tls-properties
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,6 +62,21 @@
"markdownDescription":"An external command that outputs additional HTTP headers added to all requests. The command must output each header as `key=value` on its own line. The following environment variables will be available to the process: `CODER_URL`.",
"type":"string",
"default":""
},
"coder.tlsCertFile": {
"markdownDescription":"Path to file for TLS client cert",
"type":"string",
"default":""
},
"coder.tlsKeyFile": {
"markdownDescription":"Path to file for TLS client key",
"type":"string",
"default":""
},
"coder.tlsCaFile": {
"markdownDescription":"Path to file for TLS certificate authority",
"type":"string",
"default":""
}
}
},
Expand Down
30 changes: 23 additions & 7 deletionssrc/extension.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
"use strict"
importaxiosfrom"axios"
import{getAuthenticatedUser}from"coder/site/src/api/api"
importfsfrom"fs"
import*ashttpsfrom"https"
import*asmodulefrom"module"
import*asvscodefrom"vscode"
Expand DownExpand Up@@ -30,13 +31,21 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
false,
)

// updateInsecure is called on extension activation and when the insecure
// setting is changed. It updates the https agent to allow self-signed
// certificates if the insecure setting is true.
constapplyInsecure=()=>{
constinsecure=Boolean(vscode.workspace.getConfiguration().get("coder.insecure"))
// applyHttpProperties is called on extension activation and when the
// insecure or TLS setting are changed. It updates the https agent to allow
// self-signed certificates if the insecure setting is true, as well as
// adding cert/key/ca properties for TLS.
constapplyHttpProperties=()=>{
constcfg=vscode.workspace.getConfiguration()
constinsecure=Boolean(cfg.get("coder.insecure"))
constcertFile=String(cfg.get("coder.tlsCertFile"))
constkeyFile=String(cfg.get("coder.tlsKeyFile"))
constcaFile=String(cfg.get("coder.tlsCaFile"))

axios.defaults.httpsAgent=newhttps.Agent({
cert:certFile==="" ?undefined :fs.readFileSync(certFile),
key:keyFile==="" ?undefined :fs.readFileSync(keyFile),
ca:caFile==="" ?undefined :fs.readFileSync(caFile),
// rejectUnauthorized defaults to true, so we need to explicitly set it to false
// if we want to allow self-signed certificates.
rejectUnauthorized:!insecure,
Expand All@@ -51,9 +60,16 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
)

vscode.workspace.onDidChangeConfiguration((e)=>{
e.affectsConfiguration("coder.insecure")&&applyInsecure()
if(
e.affectsConfiguration("coder.insecure")||
e.affectsConfiguration("coder.tlsCertFile")||
e.affectsConfiguration("coder.tlsKeyFile")||
e.affectsConfiguration("coder.tlsCaFile")
){
applyHttpProperties()
}
})
applyInsecure()
applyHttpProperties()

constoutput=vscode.window.createOutputChannel("Coder")
conststorage=newStorage(output,ctx.globalState,ctx.secrets,ctx.globalStorageUri,ctx.logUri)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp