Spaces:
Running
Running
Lock MCP auth with 401 gate, restore previous workspace memory in code-server, and use fallback npx for supergateway
Browse files- Dockerfile +1 -2
- config/Caddyfile.example +10 -1
- entrypoint.sh +2 -5
- services/05-code-server.sh +0 -1
- services/15-supergateway.sh +7 -10
Dockerfile
CHANGED
|
@@ -194,8 +194,7 @@ RUN curl -fsSL "https://github.com/oven-sh/bun/releases/latest/download/bun-linu
|
|
| 194 |
# ------------------------------------------
|
| 195 |
COPY security/stub-playwright-index.js /tmp/stub-pw.js
|
| 196 |
COPY security/stub-playwright-index.mjs /tmp/stub-pw.mjs
|
| 197 |
-
RUN npm
|
| 198 |
-
npm install -g supergateway@latest rea-agents@latest opencode-ai @deepseek-ai/dsh aicodeman@latest pnpm yarn typescript && \
|
| 199 |
chmod +x /usr/local/bin/* 2>/dev/null || true && \
|
| 200 |
cp /tmp/stub-pw.js /usr/local/lib/node_modules/rea-agents/node_modules/playwright-core/index.js 2>/dev/null || true && \
|
| 201 |
cp /tmp/stub-pw.mjs /usr/local/lib/node_modules/rea-agents/node_modules/playwright-core/index.mjs 2>/dev/null || true && \
|
|
|
|
| 194 |
# ------------------------------------------
|
| 195 |
COPY security/stub-playwright-index.js /tmp/stub-pw.js
|
| 196 |
COPY security/stub-playwright-index.mjs /tmp/stub-pw.mjs
|
| 197 |
+
RUN npm install -g supergateway@4.1.0 rea-agents@latest opencode-ai @deepseek-ai/dsh aicodeman@latest pnpm yarn typescript --prefix /usr/local && \
|
|
|
|
| 198 |
chmod +x /usr/local/bin/* 2>/dev/null || true && \
|
| 199 |
cp /tmp/stub-pw.js /usr/local/lib/node_modules/rea-agents/node_modules/playwright-core/index.js 2>/dev/null || true && \
|
| 200 |
cp /tmp/stub-pw.mjs /usr/local/lib/node_modules/rea-agents/node_modules/playwright-core/index.mjs 2>/dev/null || true && \
|
config/Caddyfile.example
CHANGED
|
@@ -1,5 +1,14 @@
|
|
| 1 |
:7860 {
|
| 2 |
-
# 1. REA MCP Server (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
handle /mcp* {
|
| 4 |
reverse_proxy 127.0.0.1:8093 {
|
| 5 |
flush_interval -1
|
|
|
|
| 1 |
:7860 {
|
| 2 |
+
# 1. REA MCP Server (Strict Token Authentication via Caddy)
|
| 3 |
+
@mcp_unauth {
|
| 4 |
+
path /mcp*
|
| 5 |
+
not header Authorization "Bearer @man.g"
|
| 6 |
+
not header X-API-Key "@man.g"
|
| 7 |
+
}
|
| 8 |
+
respond @mcp_unauth "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Unauthorized: Bearer token or X-API-Key required.\"},\"id\":null}" 401 {
|
| 9 |
+
close
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
handle /mcp* {
|
| 13 |
reverse_proxy 127.0.0.1:8093 {
|
| 14 |
flush_interval -1
|
entrypoint.sh
CHANGED
|
@@ -38,11 +38,8 @@ for f in /app/services/*.sh; do
|
|
| 38 |
done
|
| 39 |
|
| 40 |
# 2. Persistent Caddyfile on /data (user-editable):
|
| 41 |
-
#
|
| 42 |
-
|
| 43 |
-
echo "📋 Restoring valid /data/Caddyfile from /app/config/Caddyfile.example..."
|
| 44 |
-
cp /app/config/Caddyfile.example /data/Caddyfile
|
| 45 |
-
fi
|
| 46 |
|
| 47 |
# 3. Enforce Browser Lockdown
|
| 48 |
rm -rf /root/.cache/ms-playwright /root/.cache/puppeteer /tmp/.cache/ms-playwright 2>/dev/null || true
|
|
|
|
| 38 |
done
|
| 39 |
|
| 40 |
# 2. Persistent Caddyfile on /data (user-editable):
|
| 41 |
+
# Always sync from template to apply latest routing rules and remove stale directives
|
| 42 |
+
cp /app/config/Caddyfile.example /data/Caddyfile
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# 3. Enforce Browser Lockdown
|
| 45 |
rm -rf /root/.cache/ms-playwright /root/.cache/puppeteer /tmp/.cache/ms-playwright 2>/dev/null || true
|
services/05-code-server.sh
CHANGED
|
@@ -56,5 +56,4 @@ exec code-server \
|
|
| 56 |
--bind-addr 127.0.0.1:8443 \
|
| 57 |
--disable-telemetry \
|
| 58 |
--disable-update-check \
|
| 59 |
-
"$WORKSPACE" \
|
| 60 |
>> "$LOG" 2>&1
|
|
|
|
| 56 |
--bind-addr 127.0.0.1:8443 \
|
| 57 |
--disable-telemetry \
|
| 58 |
--disable-update-check \
|
|
|
|
| 59 |
>> "$LOG" 2>&1
|
services/15-supergateway.sh
CHANGED
|
@@ -44,14 +44,16 @@ CMD="/usr/local/bin/supergateway"
|
|
| 44 |
if [ ! -x "$CMD" ]; then
|
| 45 |
CMD="$(command -v supergateway || find /usr -name supergateway 2>/dev/null | head -1)"
|
| 46 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
REA_CMD="/usr/local/bin/rea"
|
| 48 |
if [ ! -x "$REA_CMD" ]; then
|
| 49 |
REA_CMD="$(command -v rea || find /usr -name rea 2>/dev/null | head -1)"
|
| 50 |
fi
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
echo "ERROR: supergateway binary not found or not executable: $CMD" >> "$LOG"
|
| 54 |
-
exit 1
|
| 55 |
fi
|
| 56 |
|
| 57 |
ARGS=(
|
|
@@ -61,11 +63,6 @@ ARGS=(
|
|
| 61 |
--port 8093
|
| 62 |
--streamableHttpPath /mcp
|
| 63 |
--healthEndpoint /healthz
|
| 64 |
-
--healthCheck server
|
| 65 |
)
|
| 66 |
|
| 67 |
-
|
| 68 |
-
ARGS+=(--apiKey "$API_KEY")
|
| 69 |
-
fi
|
| 70 |
-
|
| 71 |
-
exec "$CMD" "${ARGS[@]}" >> "$LOG" 2>&1
|
|
|
|
| 44 |
if [ ! -x "$CMD" ]; then
|
| 45 |
CMD="$(command -v supergateway || find /usr -name supergateway 2>/dev/null | head -1)"
|
| 46 |
fi
|
| 47 |
+
if [ -z "$CMD" ] || [ ! -x "$CMD" ]; then
|
| 48 |
+
CMD="npx -y supergateway@4.1.0"
|
| 49 |
+
fi
|
| 50 |
+
|
| 51 |
REA_CMD="/usr/local/bin/rea"
|
| 52 |
if [ ! -x "$REA_CMD" ]; then
|
| 53 |
REA_CMD="$(command -v rea || find /usr -name rea 2>/dev/null | head -1)"
|
| 54 |
fi
|
| 55 |
+
if [ -z "$REA_CMD" ] || [ ! -x "$REA_CMD" ]; then
|
| 56 |
+
REA_CMD="npx -y rea-agents@latest"
|
|
|
|
|
|
|
| 57 |
fi
|
| 58 |
|
| 59 |
ARGS=(
|
|
|
|
| 63 |
--port 8093
|
| 64 |
--streamableHttpPath /mcp
|
| 65 |
--healthEndpoint /healthz
|
|
|
|
| 66 |
)
|
| 67 |
|
| 68 |
+
exec $CMD "${ARGS[@]}" >> "$LOG" 2>&1
|
|
|
|
|
|
|
|
|
|
|
|