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
+19 -2
View File
@@ -149,6 +149,19 @@ function session(req) {
}
}
/**
* The derived id the server keys step-up elevation by (AuthStore.sessionId),
* or "" without a live session. Forwarded on /connect and POST /files only.
*/
function elevationSession(req) {
if (!auth) return "";
try {
return store.sessionId(sessionValue(req));
} catch {
return "";
}
}
function isAuthed(req) {
return !auth || session(req) !== null;
}
@@ -444,8 +457,10 @@ async function serveIndex(res) {
*/
function proxyArtifact(req, res) {
let headers;
// An upload is gated by the session's elevation on the server.
const upload = req.method === "POST" && (req.url ?? "").split("?")[0] === "/files";
try {
headers = withServerToken(req.headers);
headers = withServerToken(req.headers, undefined, upload ? elevationSession(req) : "");
} catch {
res.writeHead(503, { "Content-Type": "text/plain; charset=utf-8" }).end("Server token unavailable");
return;
@@ -667,7 +682,9 @@ const targetHost = pipelinesTarget.slice(0, pipelinesTarget.lastIndexOf(":")) ||
function proxyUpgrade(req, clientSocket, clientHead) {
let headers;
try {
headers = withServerToken(req.headers);
// The server keys step-up elevation by this session, so a reconnect of
// the same sign-in stays elevated.
headers = withServerToken(req.headers, undefined, elevationSession(req));
} catch {
clientSocket.end("HTTP/1.1 503 Service Unavailable\r\nContent-Length: 0\r\n\r\n");
return;