fix(tunnel): give the unauthenticated tunnel its own acknowledgement

The network acknowledgement that install.sh writes for every passwordless LAN install also satisfied the tunnel guard, so one click on the welcome screen's tunnel link published full terminal control to a public URL with no login and no confirm. The tunnel now needs CODEMAN_ALLOW_UNAUTHENTICATED_TUNNEL or --allow-unauthenticated-tunnel (carried by web -d and service install), and with no login the browser asks before every enable, reading a new loginConfigured field from GET /api/tunnel/status.

The guard is now decided once per request and required again where the tunnel starts, so a save that found the tunnel running can no longer restart it unguarded after a concurrent stop.

Closes #706
This commit is contained in:
JD committed 2026-10-26 03:13:25 -04:00
1 parent 3e06f3c141
commit fc0ecc6051
26 files changed
+1029 -165

No files matched your search

+18 -3
View File
@@ -472,6 +472,8 @@ export class WebServer extends EventEmitter {
private windowTitle: string;
private readonly indexHtmlTemplate: string;
private readonly allowUnauthenticatedNetwork: boolean;
/** `--allow-unauthenticated-tunnel`; the tunnel guard reads it through the route context (#706). */
private readonly allowUnauthenticatedTunnel: boolean;
private _pasteImageGcStop: (() => void) | null = null;
private _eventLoopMonitor: EventLoopMonitorHandle | null = null;
/** Opt-in hooks-only listener on the docker bridge gateway (CODEMAN_DOCKER_BRIDGE_HOOKS). */
@@ -489,7 +491,8 @@ export class WebServer extends EventEmitter {
host: string = '127.0.0.1',
titleHostname?: string,
allowUnauthenticatedNetwork: boolean = false,
basePath: string = ''
basePath: string = '',
allowUnauthenticatedTunnel: boolean = false
) {
super();
this.setMaxListeners(0);
@@ -501,6 +504,7 @@ export class WebServer extends EventEmitter {
this.testMode = testMode;
this.allowUnauthenticatedNetwork =
allowUnauthenticatedNetwork || isExplicitlyEnabled(process.env.CODEMAN_ALLOW_UNAUTHENTICATED_NETWORK);
this.allowUnauthenticatedTunnel = allowUnauthenticatedTunnel;
this.titleHostname = titleHostname || getHostname();
this.windowTitle = `codeman:${this.titleHostname}`;
this.indexHtmlTemplate = readFileSync(join(__dirname, 'public', 'index.html'), 'utf-8');
@@ -880,6 +884,7 @@ export class WebServer extends EventEmitter {
scheduledRuns: this.scheduledRuns,
teamWatcher: this.teamWatcher,
tunnelManager: this.tunnelManager,
allowUnauthenticatedTunnel: this.allowUnauthenticatedTunnel,
pushStore: this.pushStore,
startScheduledRun: this.startScheduledRun.bind(this),
stopScheduledRun: this.stopScheduledRun.bind(this),
@@ -4399,9 +4404,19 @@ export async function startWebServer(
host: string = '127.0.0.1',
titleHostname?: string,
allowUnauthenticatedNetwork: boolean = false,
basePath: string = ''
basePath: string = '',
allowUnauthenticatedTunnel: boolean = false
): Promise<WebServer> {
const server = new WebServer(port, https, testMode, host, titleHostname, allowUnauthenticatedNetwork, basePath);
const server = new WebServer(
port,
https,
testMode,
host,
titleHostname,
allowUnauthenticatedNetwork,
basePath,
allowUnauthenticatedTunnel
);
await server.start();
return server;
}