Skip to content

Commit 245befb

Browse files
feat: add passwordFile and hashedPasswordFile options
1 parent f999968 commit 245befb

File tree

8 files changed

+78
-0
lines changed

8 files changed

+78
-0
lines changed

src/code-server/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ VS Code in the browser
2929
| disableWorkspaceTrust | Disable Workspace Trust feature. This only affects the current session. | boolean | false |
3030
| enableProposedAPI | Comma-separated list of VS Code extension IDs to enable proposed API features for. | string | - |
3131
| extensions | Comma-separated list of VS Code extensions to install. Format: 'publisher.extension[@version]' (e.g., 'ms-python.python,ms-azuretools.vscode-docker'). | string | - |
32+
| hashedPasswordFile | Path to a file containing the hashed password used for authentication. The password should be hashed with argon2 and be in the encoded form. This takes priority over `passwordFile`. | string | - |
3233
| host | The address to bind to for the code-server. Use '0.0.0.0' to listen on all interfaces. | string | 127.0.0.1 |
3334
| locale | Set VS Code display language and language shown on the login page. Format should be an IETF language tag (e.g., 'en', 'fr', 'zh-CN'). | string | - |
3435
| logFile | Path to a file to send stdout and stderr logs to from code-server. | string | /tmp/code-server.log |
36+
| passwordFile | Path to a file containing the password used for authentication. | string | - |
3537
| port | The port to bind to for the code-server. | string | 8080 |
3638
| proxyDomain | Domain used for proxying ports. | string | - |
3739
| socket | Path to a socket. When specified, host and port will be ignored. | string | - |

src/code-server/devcontainer-feature.json

+10
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
"default": "",
7676
"description": "Comma-separated list of VS Code extensions to install. Format: 'publisher.extension[@version]' (e.g., 'ms-python.python,ms-azuretools.vscode-docker')."
7777
},
78+
"hashedPasswordFile": {
79+
"type": "string",
80+
"default": "",
81+
"description": "Path to a file containing the hashed password used for authentication. The password should be hashed with argon2 and be in the encoded form. This takes priority over `passwordFile`."
82+
},
7883
"host": {
7984
"type": "string",
8085
"default": "127.0.0.1",
@@ -90,6 +95,11 @@
9095
"default": "/tmp/code-server.log",
9196
"description": "Path to a file to send stdout and stderr logs to from code-server."
9297
},
98+
"passwordFile": {
99+
"type": "string",
100+
"default": "",
101+
"description": "Path to a file containing the password used for authentication."
102+
},
93103
"port": {
94104
"type": "string",
95105
"default": "8080",

src/code-server/install.sh

+8
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ fi
116116
117117
$(declare -p FLAGS)
118118
119+
if [[ -f "$PASSWORDFILE" ]]; then
120+
export PASSWORD="\$(cat '$PASSWORDFILE')"
121+
fi
122+
123+
if [[ -f "$HASHEDPASSWORDFILE" ]]; then
124+
export HASHED_PASSWORD="\$(cat '$HASHEDPASSWORDFILE')"
125+
fi
126+
119127
code-server "\${FLAGS[@]}" "$CODE_SERVER_WORKSPACE" >"$LOGFILE" 2>&1
120128
EOF
121129

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server hashed-password-file" grep $'export HASHED_PASSWORD="$(cat \'/tmp/code-server-hashed-password\')"' < /usr/local/bin/code-server-entrypoint
13+
check "code-server hashed-password" grep 'Using password from $HASHED_PASSWORD' < /tmp/code-server.log
14+
15+
# Report results
16+
reportResults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu
2+
3+
RUN su vscode -c 'echo "\$argon2id\$v=19\$m=16,t=2,p=1\$c2FtcGxlc2FsdA\$YBn10Qizrh/i2jf/rPOCCA" > /tmp/code-server-hashed-password'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server password-file" grep $'export PASSWORD="$(cat \'/tmp/code-server-password\')"' < /usr/local/bin/code-server-entrypoint
13+
check "code-server password" grep 'Using password from $PASSWORD' < /tmp/code-server.log
14+
15+
# Report results
16+
reportResults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu
2+
3+
RUN su vscode -c "echo 'some sample password' > /tmp/code-server-password"

test/code-server/scenarios.json

+20
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,25 @@
227227
"proxyDomain": "dev.coder.com"
228228
}
229229
}
230+
},
231+
"code-server-password-file": {
232+
"build": {
233+
"dockerfile": "Dockerfile"
234+
},
235+
"features": {
236+
"code-server": {
237+
"passwordFile": "/tmp/code-server-password"
238+
}
239+
}
240+
},
241+
"code-server-hashed-password-file": {
242+
"build": {
243+
"dockerfile": "Dockerfile"
244+
},
245+
"features": {
246+
"code-server": {
247+
"hashedPasswordFile": "/tmp/code-server-hashed-password"
248+
}
249+
}
230250
}
231251
}

0 commit comments

Comments
 (0)