From 25cda1026b9fc9390103ae1629f8b39680b9a7cc Mon Sep 17 00:00:00 2001 From: luxick Date: Tue, 6 Jan 2026 21:40:58 +0100 Subject: [PATCH] Remove token from client --- README.md | 24 +++----------- install-linux.sh | 38 +++------------------- install-windows-task.ps1 | 41 ++---------------------- internal/openfolder/open_linux.go | 2 +- main.go | 53 +------------------------------ uninstall-linux.sh | 2 +- 6 files changed, 13 insertions(+), 147 deletions(-) diff --git a/README.md b/README.md index d5fb6e5..687ed24 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,9 @@ go build -o luxtools-client . ./luxtools-client ``` -On startup, if you don’t pass `-token`, the server generates a random token and prints it to the logs. Put that token into the Dokuwiki plugin configuration. - ### Flags - `-listen` (default `127.0.0.1:8765`): listen address (`host:port`). Must be loopback. -- `-token` (default empty): shared secret token. If empty, a token is generated and logged at startup. - `-allow` (repeatable): allowed path prefix. If you specify one or more, the requested path must start with one of them. Examples: @@ -42,9 +39,6 @@ Examples: # Listen on a different local port ./luxtools-client -listen 127.0.0.1:9000 -# Use an explicit token (recommended for stable config) -./luxtools-client -token "your-shared-secret" - # Restrict opens to your home directory (repeat -allow as needed) ./luxtools-client -allow "$HOME" ``` @@ -53,7 +47,6 @@ Examples: The scripts below install (or update) the client as a service that starts automatically with the system. They assume the client binary already exists in the same folder as the scripts. -During install/update, the scripts prompt you for the shared token (press Enter to keep the current token, if already configured). ### Linux (systemd) @@ -79,7 +72,7 @@ Uninstall: ./uninstall-linux.sh ``` -Keep token/config on uninstall: +Keep config on uninstall: ```bash ./uninstall-linux.sh --keep-config @@ -89,7 +82,7 @@ Notes: - Installs to `~/.local/share/luxtools-client/luxtools-client` - Creates a systemd *user* unit at `~/.config/systemd/user/luxtools-client.service` -- Stores config (including the token) in `~/.config/luxtools-client/luxtools-client.env` +- Stores config in `~/.config/luxtools-client/luxtools-client.env` ### Windows (Scheduled Task at logon) @@ -116,7 +109,7 @@ Uninstall: uninstall-windows-task.bat ``` -Keep token/config on uninstall: +Keep config on uninstall: ```bat uninstall-windows-task.bat --keep-config @@ -125,18 +118,11 @@ uninstall-windows-task.bat --keep-config Notes: - Installs to `%LOCALAPPDATA%\luxtools-client\luxtools-client.exe` -- Stores config (including the token) in `%LOCALAPPDATA%\luxtools-client\config.json` +- Stores config in `%LOCALAPPDATA%\luxtools-client\config.json` - Re-running the install script updates the EXE in place and restarts the task. ## API -### Auth - -Requests must include the token using the `X-Luxtools-Token` header. - -- Header: `X-Luxtools-Token: ` -- For `GET /open`, a `token=...` query parameter is also accepted as a fallback. - ### `GET /health` Returns JSON: @@ -164,7 +150,6 @@ Example: ```bash curl -sS -X POST \ -H 'Content-Type: application/json' \ - -H 'X-Luxtools-Token: your-shared-secret' \ --data '{"path":"/tmp"}' \ http://127.0.0.1:8765/open ``` @@ -177,7 +162,6 @@ Example: ```bash curl -i \ - -H 'X-Luxtools-Token: your-shared-secret' \ 'http://127.0.0.1:8765/open?path=/tmp' ``` diff --git a/install-linux.sh b/install-linux.sh index 5906e45..470ce2b 100755 --- a/install-linux.sh +++ b/install-linux.sh @@ -17,7 +17,7 @@ Usage: $0 [--listen host:port] [--allow ]... Installs/updates ${SERVICE_NAME} as a systemd *user* service (runs under your current user). - Re-running updates the installed binary and restarts the service. -- A stable token is stored in ${ENV_FILE} (created on first install). +- Config is stored in ${ENV_FILE} (created on first install). Options: --listen host:port Listen address (default: ${DEFAULT_LISTEN}) @@ -74,48 +74,19 @@ cp "$SRC_BIN" "$TMP_BIN" chmod 0755 "$TMP_BIN" || true if [[ -f "$ENV_FILE" ]]; then - # Preserve existing config (especially TOKEN). + # Preserve existing config. # shellcheck disable=SC1090 source "$ENV_FILE" || true fi -CURRENT_TOKEN="${TOKEN:-}" -SUGGESTED_TOKEN="" -if [[ -z "${CURRENT_TOKEN}" ]]; then - if command -v openssl >/dev/null 2>&1; then - SUGGESTED_TOKEN="$(openssl rand -base64 32 | tr '+/' '-_' | tr -d '=\n\r')" - else - SUGGESTED_TOKEN="$(head -c 32 /dev/urandom | base64 | tr '+/' '-_' | tr -d '=\n\r')" - fi -fi - -echo -if [[ -n "${CURRENT_TOKEN}" ]]; then - echo "A token is already configured. Press Enter to keep it, or paste a new one." -else - echo "No token configured yet. Press Enter to use a generated token, or paste your own." -fi -read -r -s -p "Token: " TOKEN_INPUT -echo - -if [[ -n "${TOKEN_INPUT}" ]]; then - TOKEN="${TOKEN_INPUT}" -elif [[ -n "${CURRENT_TOKEN}" ]]; then - TOKEN="${CURRENT_TOKEN}" -else - TOKEN="${SUGGESTED_TOKEN}" -fi - cat >"$ENV_FILE" <