Skip to content

Commit 52099ea

Browse files
CopilotFoorackCopilot
committed
Add trusted_domains variable to code-server module for link protection (#1)
* Initial plan * Add trusted_domains variable to code-server module for link protection Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com> * Remove temporary plan files from commit Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com> * Refactor TRUSTED_DOMAINS_ARG to match EXTENSION_ARG pattern Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com> * Remove trusted domains tests as requested Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com> * Fix trusted domains to use multiple flag instances instead of comma-separated values Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com> * Update registry/coder/modules/code-server/run.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update registry/coder/modules/code-server/run.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Foorack <5008081+Foorack@users.noreply.github.com> Co-authored-by: Foorack / Max Faxälv <max@foorack.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 60fec19 commit 52099ea

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

registry/coder/modules/code-server/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ variable "open_in" {
148148
}
149149
}
150150

151+
variable "trusted_domains" {
152+
type = list(string)
153+
description = "A list of trusted domains for link protection. These domains will be added to the --link-protection-trusted-domains option."
154+
default = []
155+
}
156+
151157
resource "coder_script" "code-server" {
152158
agent_id = var.agent_id
153159
display_name = "code-server"
@@ -168,6 +174,7 @@ resource "coder_script" "code-server" {
168174
EXTENSIONS_DIR : var.extensions_dir,
169175
FOLDER : var.folder,
170176
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
177+
TRUSTED_DOMAINS : join(",", var.trusted_domains),
171178
})
172179
run_on_start = true
173180

registry/coder/modules/code-server/run.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,22 @@ if [ -n "${EXTENSIONS_DIR}" ]; then
1313
mkdir -p "${EXTENSIONS_DIR}"
1414
fi
1515

16+
# Set trusted domains argument
17+
TRUSTED_DOMAINS_ARG=""
18+
if [ -n "${TRUSTED_DOMAINS}" ]; then
19+
# Split comma-separated domains and create multiple --link-protection-trusted-domains arguments
20+
IFS=',' read -r -a DOMAINS_ARRAY <<< "${TRUSTED_DOMAINS}"
21+
for domain in "${DOMAINS_ARRAY[@]}"; do
22+
if [ -n "$domain" ]; then
23+
TRUSTED_DOMAINS_ARG="$TRUSTED_DOMAINS_ARG --link-protection-trusted-domains=${domain}"
24+
fi
25+
done
26+
fi
27+
1628
function run_code_server() {
1729
echo "👷 Running code-server in the background..."
1830
echo "Check logs at ${LOG_PATH}!"
19-
$CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
31+
$CODE_SERVER $EXTENSION_ARG $TRUSTED_DOMAINS_ARG --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
2032
}
2133

2234
# Check if the settings file exists...

0 commit comments

Comments
 (0)