Skip to content

Commit fa84e43

Browse files
authored
fix(gateway): configure local dev auth (#1575)
This makes it so you can run the dev gateway and sandbox with: ``` mise run gateway # in another shell mise run sandbox ``` Signed-off-by: Kris Hicks <khicks@nvidia.com>
1 parent 3460e5f commit fa84e43

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

tasks/scripts/gateway-docker.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ echo "Building openshell-gateway..."
127127
cargo build ${CARGO_BUILD_JOBS_ARG[@]+"${CARGO_BUILD_JOBS_ARG[@]}"} \
128128
-p openshell-server --bin openshell-gateway
129129

130+
TLS_DIR="${STATE_DIR}/tls"
131+
echo "Generating local gateway credentials..."
132+
"${GATEWAY_BIN}" generate-certs \
133+
--output-dir "${TLS_DIR}" \
134+
--server-san "127.0.0.1" \
135+
--server-san "localhost" \
136+
--server-san "host.openshell.internal"
137+
130138
echo "Building openshell-sandbox for ${SUPERVISOR_TARGET}..."
131139
if [[ "${HOST_OS}" == "Linux" && "${HOST_ARCH}" == "${DAEMON_ARCH}" ]]; then
132140
# Native Linux build — no cross-toolchain required.
@@ -165,6 +173,16 @@ version = 1
165173
compute_drivers = ["docker"]
166174
disable_tls = true
167175
176+
[openshell.gateway.auth]
177+
allow_unauthenticated_users = true
178+
179+
[openshell.gateway.gateway_jwt]
180+
signing_key_path = "${TLS_DIR}/jwt/signing.pem"
181+
public_key_path = "${TLS_DIR}/jwt/public.pem"
182+
kid_path = "${TLS_DIR}/jwt/kid"
183+
gateway_id = "${GATEWAY_NAME}"
184+
ttl_secs = 3600
185+
168186
[openshell.drivers.docker]
169187
default_image = "${SANDBOX_IMAGE}"
170188
image_pull_policy = "${SANDBOX_IMAGE_PULL_POLICY}"

tasks/scripts/gateway-vm.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ if [ "$(uname -s)" = "Darwin" ]; then
307307
"${DRIVER_DIR}/openshell-driver-vm"
308308
fi
309309

310+
TLS_DIR="${STATE_DIR}/tls"
311+
echo "==> Generating local gateway credentials"
312+
"${GATEWAY_BIN}" generate-certs \
313+
--output-dir "${TLS_DIR}" \
314+
--server-san "127.0.0.1" \
315+
--server-san "localhost" \
316+
--server-san "host.openshell.internal"
317+
310318
mkdir -p "${STATE_DIR}"
311319
mkdir -p "${VM_DRIVER_STATE_DIR}"
312320
chmod 700 "${VM_DRIVER_STATE_DIR}"
@@ -319,6 +327,16 @@ version = 1
319327
compute_drivers = ["vm"]
320328
disable_tls = ${DISABLE_TLS}
321329
330+
[openshell.gateway.auth]
331+
allow_unauthenticated_users = true
332+
333+
[openshell.gateway.gateway_jwt]
334+
signing_key_path = "${TLS_DIR}/jwt/signing.pem"
335+
public_key_path = "${TLS_DIR}/jwt/public.pem"
336+
kid_path = "${TLS_DIR}/jwt/kid"
337+
gateway_id = "${GATEWAY_NAME}"
338+
ttl_secs = 3600
339+
322340
[openshell.drivers.vm]
323341
default_image = "${SANDBOX_IMAGE}"
324342
bootstrap_image = "${VM_BOOTSTRAP_IMAGE}"

tasks/scripts/gateway.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ if [[ ! -x "${GATEWAY_BIN}" ]]; then
291291
exit 1
292292
fi
293293

294+
TLS_DIR="${STATE_DIR}/tls"
295+
echo "Generating local gateway credentials..."
296+
"${GATEWAY_BIN}" generate-certs \
297+
--output-dir "${TLS_DIR}" \
298+
--server-san "127.0.0.1" \
299+
--server-san "localhost" \
300+
--server-san "host.openshell.internal"
301+
294302
mkdir -p "${STATE_DIR}"
295303
CONFIG_PATH="${STATE_DIR}/gateway.toml"
296304
cat >"${CONFIG_PATH}" <<EOF
@@ -301,6 +309,16 @@ version = 1
301309
compute_drivers = ["${DRIVER}"]
302310
default_image = "${SANDBOX_IMAGE}"
303311
disable_tls = true
312+
313+
[openshell.gateway.auth]
314+
allow_unauthenticated_users = true
315+
316+
[openshell.gateway.gateway_jwt]
317+
signing_key_path = "${TLS_DIR}/jwt/signing.pem"
318+
public_key_path = "${TLS_DIR}/jwt/public.pem"
319+
kid_path = "${TLS_DIR}/jwt/kid"
320+
gateway_id = "${GATEWAY_NAME}"
321+
ttl_secs = 3600
304322
EOF
305323

306324
case "${DRIVER}" in

0 commit comments

Comments
 (0)