Prepares the daemon to be reachable off loopback as part of the server-client migration (see the approved implementation plan). Today it trusts any caller that can reach the port; this makes every route except health checks and login require a bearer session token. - New frontend.worker.db-worker-node-auth: scrypt-hashed username/password credential persisted at <root-dir>/db-worker-auth.json (mode 0600), bootstrapped from LOGSEQ_DAEMON_USERNAME/PASSWORD on first launch since there's no interactive setup yet. In-memory bearer sessions with constant-time comparison, a failed-login lockout, and list/revoke by device. The daemon now refuses to start with no credential configured at all -- not just when binding beyond loopback -- since without one no token could ever be issued. - db_worker_node.cljs: POST /v1/auth/login and GET/DELETE /v1/auth/sessions; every other route requires Authorization: Bearer except /healthz, which stays open (readiness polling happens before any session exists) but now omits :pid/:root-dir from its payload. Adds a Host-header allowlist ahead of auth to guard against DNS rebinding, and configurable --host/--port/--allowed-origin/--allowed-host in place of the hardcoded 127.0.0.1 bind and single CORS origin. - EventSource can't send custom headers, so /v1/events accepts the bearer token as a query param instead; persist_db/remote.cljs's events-url carries it there now (interim until the Fase 4 WebSocket migration). - Electron always sent :auth-token nil (verified by reading db_worker.cljs -- one of the plan's open questions). daemon/spawn-server! now seeds a per-root-dir local device credential (<root-dir>/db-worker-local-credential.json, reused across restarts) via LOGSEQ_DAEMON_USERNAME/PASSWORD, and cli/server.cljs logs in once the spawned or reused daemon is ready, threading the resulting token through ensure-server! to Electron's runtime config. Not done: the OCaml CLI (cli/lib/transport.ml) also calls /v1/invoke directly and will start receiving 401s once this ships -- confirmed with the user to leave that gap for now rather than touch the OCaml toolchain in this pass. Verified with clojure -M:cljs compile app db-worker-node electron (0 warnings) and the full logseq.db-worker.daemon-test, logseq.cli.server-test, frontend.worker.db-worker-node-test, electron.db-worker-manager-test suites (113 tests, 480 assertions, 0 failures) plus frontend.state-test and frontend.persist-db.remote-test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
49 lines
575 B
Plaintext
49 lines
575 B
Plaintext
# Dependencies
|
|
node_modules/
|
|
.pnpm-store/
|
|
|
|
# Clojure/ClojureScript build
|
|
.cpcache/
|
|
.clj-kondo/.cache/
|
|
.shadow-cljs/
|
|
target/
|
|
out/
|
|
.nrepl-port
|
|
.lsp/.cache/
|
|
|
|
# Build output
|
|
static/
|
|
dist/
|
|
cli/_build/
|
|
cli/**/*.install
|
|
resources/.cache/
|
|
|
|
# Test run temp dirs (frontend.test.node-helper/create-tmp-dir)
|
|
tmp/
|
|
|
|
# OCaml/Dune
|
|
cli/_opam/
|
|
|
|
# Env / secrets
|
|
.env
|
|
.env.*
|
|
*.pem
|
|
*.key
|
|
|
|
# OS / editor
|
|
.DS_Store
|
|
*.log
|
|
.vscode/
|
|
.idea/
|
|
|
|
# Python sidecar
|
|
sidecar/.venv/
|
|
sidecar/__pycache__/
|
|
**/__pycache__/
|
|
|
|
# Mobile build artifacts
|
|
android/app/build/
|
|
android/.gradle/
|
|
ios/App/Pods/
|
|
ios/App/build/
|