Skip to main content
← Back to list
01Issue
FeatureShippedSwamp CLI
Assigneesstack72

Relationships

#996 Add --server-token to worker connect for authenticated orchestrators

Opened by stack72 · 7/6/2026· Shipped 7/6/2026

Summary

When `swamp serve` runs with `--auth-mode token` (required for off-loopback binding), every WebSocket connection must include a `?token=` query parameter with a valid server access token. Workers have no way to pass this — `SWAMP_WORKER_TOKEN` is the enrollment token, not the server access token.

This means no worker can connect to a TLS-authenticated orchestrator without embedding the server token in the `SWAMP_ORCHESTRATOR_URL` as a query parameter (e.g., `wss://host:9090?token=admin.secret`), which leaks the token in process listings and environment dumps.

Fix

Add `--server-token` flag and `SWAMP_SERVER_TOKEN` env var to `swamp worker connect`:

```bash swamp worker connect wss://orch:9090 \ --server-token admin.secret \ --token worker-pool.enrollment-secret \ --label tier=ci ```

Or via env var:

```bash SWAMP_ORCHESTRATOR_URL=wss://orch:9090 SWAMP_SERVER_TOKEN=admin.secret SWAMP_WORKER_TOKEN=worker-pool.enrollment-secret swamp worker connect ```

The worker appends `?token=` to the WebSocket URL before connecting. The server token authenticates the WebSocket upgrade; the enrollment token authenticates the worker identity inside the RPC handshake.

Changes

  • `src/cli/commands/worker_connect.ts`: Add `--server-token` flag with `SWAMP_SERVER_TOKEN` env var fallback
  • `src/worker/connect.ts`: Accept `serverToken?: string` in `RunWorkerOptions`, append as `?token=` to the connect URL
  • `src/cli/commands/worker_daemon.ts`: Thread `--server-token` into the daemon env file as `SWAMP_SERVER_TOKEN`

Impact

Without this, every Docker, Kubernetes, and EC2 fleet deployment requires either:

  • Embedding the server token in the URL (leaks in process listings)
  • Running without auth (`--auth-mode none`, which is deprecated and refuses off-loopback)

This blocks production fleet deployments.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 4 MOREPR_MERGED+ 1 MORENOTIFICATION_SKIPPED

Shipped

7/6/2026, 10:49:45 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack727/6/2026, 10:09:47 PM

Sign in to post a ripple.