Skip to content

Commit cc090bf

Browse files
feat: allow modifying auth mode (#3)
Adds an auth option to code-server feature to allow modifying the auth mode of code-server.
1 parent 6f18868 commit cc090bf

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

src/code-server/devcontainer-feature.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
"workspace": {
2828
"type": "string",
2929
"default": ""
30-
}
30+
},
31+
"auth": {
32+
"type": "string",
33+
"enum": ["password", "none"],
34+
"default": "password"
35+
}
3136
},
3237
"entrypoint": "/usr/local/bin/code-server-entrypoint",
3338
"dependsOn": {

src/code-server/install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cat > /usr/local/bin/code-server-entrypoint \
2828
#!/usr/bin/env bash
2929
set -e
3030
31-
su $_REMOTE_USER -c 'code-server --bind-addr "$HOST:$PORT" "$CODE_SERVER_WORKSPACE"'
31+
su $_REMOTE_USER -c 'code-server --auth "$AUTH" --bind-addr "$HOST:$PORT" "$CODE_SERVER_WORKSPACE"'
3232
EOF
3333

3434
chmod +x /usr/local/bin/code-server-entrypoint
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 auth" grep $'\'code-server.* --auth "none" .*\'' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 auth" grep $'\'code-server.* --auth "password" .*\'' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults

test/code-server/scenarios.json

+16
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,21 @@
3838
"workspace": "/home"
3939
}
4040
}
41+
},
42+
"code-server-auth-none": {
43+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
44+
"features": {
45+
"code-server": {
46+
"auth": "none"
47+
}
48+
}
49+
},
50+
"code-server-auth-password": {
51+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
52+
"features": {
53+
"code-server": {
54+
"auth": "password"
55+
}
56+
}
4157
}
4258
}

0 commit comments

Comments
 (0)