feat: harden control panel authentication

This commit is contained in:
thanhnv
2026-07-10 23:48:12 +09:00
parent 48b1186439
commit b56f7d357e
11 changed files with 571 additions and 73 deletions
@@ -18,6 +18,7 @@ AUTH_BRIDGE_DIR="$ROOT/tmp/control-panel-local/auth-bridge"
AUTH_BRIDGE_TOKEN_FILE="$AUTH_BRIDGE_DIR/token"
AUTH_BRIDGE_PID_FILE="$AUTH_BRIDGE_DIR/bridge.pid"
AUTH_BRIDGE_LOG="$AUTH_BRIDGE_DIR/bridge.log"
AUTH_BRIDGE_AUDIT="$AUTH_BRIDGE_DIR/model-audit.jsonl"
AUTH_BRIDGE="$ROOT/packages/casan-control-panel/scripts/provider-auth-bridge.py"
CMD="${1:-status}"
@@ -43,9 +44,9 @@ start_auth_bridge() {
return 0
fi
[[ -f "$AUTH_BRIDGE" ]] || { echo "CASAN_AUTH_BRIDGE_MISSING" >&2; return 1; }
nohup python3 "$AUTH_BRIDGE" --bind 0.0.0.0 --port 20130 --token-file "$AUTH_BRIDGE_TOKEN_FILE" > "$AUTH_BRIDGE_LOG" 2>&1 &
nohup python3 "$AUTH_BRIDGE" --bind 0.0.0.0 --port 20130 --token-file "$AUTH_BRIDGE_TOKEN_FILE" --audit-log "$AUTH_BRIDGE_AUDIT" > "$AUTH_BRIDGE_LOG" 2>&1 &
echo "$!" > "$AUTH_BRIDGE_PID_FILE"
chmod 600 "$AUTH_BRIDGE_PID_FILE" "$AUTH_BRIDGE_LOG" 2>/dev/null || true
chmod 600 "$AUTH_BRIDGE_PID_FILE" "$AUTH_BRIDGE_LOG" "$AUTH_BRIDGE_AUDIT" 2>/dev/null || true
wait_url "http://127.0.0.1:20130/healthz"
}
@@ -56,6 +57,7 @@ stop_auth_bridge() {
kill "$pid" 2>/dev/null || true
rm -f "$AUTH_BRIDGE_PID_FILE"
fi
rm -f "$AUTH_BRIDGE_TOKEN_FILE"
}
need_docker() {