Skip to content

Commit efd031b

Browse files
feat: allow modifying auth mode
Adds an auth option to code-server feature to allow modifying the auto mode of code-server.
1 parent a49fbbb commit efd031b

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

src/code-server/devcontainer-feature.json

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
"extensions": {
2424
"type": "string",
2525
"default": ""
26+
},
27+
"auth": {
28+
"type": "string",
29+
"enum": ["password", "none"],
30+
"default": "password"
2631
}
2732
},
2833
"entrypoint": "/usr/local/bin/code-server-entrypoint",

src/code-server/install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cat > /usr/local/bin/code-server-entrypoint \
2222
#!/usr/bin/env bash
2323
set -e
2424
25-
su $_REMOTE_USER -c 'code-server --bind-addr "$HOST:$PORT" \$ARGS'
25+
su $_REMOTE_USER -c 'code-server --auth "$AUTH" --bind-addr "$HOST:$PORT" \$ARGS'
2626
EOF
2727

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

test/code-server/scenarios.json

+16
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,21 @@
3030
"version": "4.98.0"
3131
}
3232
}
33+
},
34+
"code-server-auth-none": {
35+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
36+
"features": {
37+
"code-server": {
38+
"auth": "none"
39+
}
40+
}
41+
},
42+
"code-server-auth-password": {
43+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
44+
"features": {
45+
"code-server": {
46+
"auth": "password"
47+
}
48+
}
3349
}
3450
}

0 commit comments

Comments
 (0)