Keep step-up elevation for the signed-in session and stop gating terminals

The proxy forwards an HMAC-derived session id (X-Pipelines-Session) on
/connect and POST /files; the server trusts it only on token-authenticated
requests and keys elevation by it, so reconnects stay elevated up to a 24 h
cap. Terminals rely on their su -l login. The app no longer forgets the
elevation on disconnect and asks again only on a fresh refusal.
This commit is contained in:
2026-11-10 03:00:45 +00:00
parent 60b4c495f1
commit 1ad85de1f1
19 changed files with 876 additions and 165 deletions
+12 -5
View File
@@ -8,6 +8,8 @@ import { homedir } from "node:os";
import { join } from "node:path";
export const SERVER_TOKEN_HEADER = "x-pipelines-token";
// The proxy's opaque id of the signed-in web session (protocol.SessionHeader).
export const SESSION_HEADER = "x-pipelines-session";
export function serverTokenPath(env = process.env) {
if (env.PIPELINES_SERVER_TOKEN_FILE) return env.PIPELINES_SERVER_TOKEN_FILE;
@@ -37,12 +39,17 @@ export function serverToken(path = serverTokenPath()) {
return cached.token;
}
// Headers for the local upstream: any client-supplied token is dropped and the
// proxy's own is set, so the browser never chooses what the server sees.
export function withServerToken(headers, token = serverToken()) {
// Headers for the local upstream: any client-supplied token or session id is
// dropped and the proxy's own token is set, so the browser never chooses what
// the server sees. session, when given, is the proxy's derived session id
// (AuthStore.sessionId), set only where the server keys elevation by it.
export function withServerToken(headers, token = serverToken(), session = "") {
const result = { ...headers };
for (const name of Object.keys(result))
if (name.toLowerCase() === SERVER_TOKEN_HEADER) delete result[name];
for (const name of Object.keys(result)) {
const lower = name.toLowerCase();
if (lower === SERVER_TOKEN_HEADER || lower === SESSION_HEADER) delete result[name];
}
if (token) result[SERVER_TOKEN_HEADER] = token;
if (token && session) result[SESSION_HEADER] = session;
return result;
}