Stop advertising the session header no handler reads

The adapter's CORS allow-list offered `X-Seal-Home-Session` and openapi
declared it as a `localSession` security scheme required on every operation —
while no handler ever consulted the header and the scheme's own description
admitted it authenticates nothing. Generated clients would fabricate a token
for a check that does not exist, and a browser client sending it could fail a
preflight against a header the server no longer offers.

Remove the header from the allow-list (it now mirrors the two headers this
adapter actually reads), drop the scheme and its `security` requirement, and
state the trust model plainly in `info.description` where an API consumer sees
it. SECURITY.md keeps the authoritative wording and points at that paragraph
instead of at a scheme that no longer exists.

The local-adapter stance itself is untouched: no authentication is added, per
`.agents/rules/security-posture.md`.
This commit is contained in:
gitea committed 2026-09-30 01:17:12 +08:00
1 parent faf26b4c5b
commit d530f9a47b
5 files changed
+19 -29

No files matched your search

+6 -1
View File
@@ -45,7 +45,12 @@ export async function handleHttpRequest(req: IncomingMessage, res: ServerRespons
// 1. CORS headers
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH");
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Seal-Corp, X-Seal-Home-Session");
// Mirrors the headers this adapter actually consults: `X-Seal-Corp` selects
// the enterprise (`extractCorpId`), `Authorization` is kept because generic
// clients attach it by default. The historic `X-Seal-Home-Session` is gone —
// no handler ever read it, and the adapter has no session to authenticate
// (openapi's info.description states that plainly).
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Seal-Corp");
if (req.method === "OPTIONS") {
res.writeHead(204);
+5
View File
@@ -102,5 +102,10 @@ describe("HTTP Server", () => {
const res = await fetch(`${baseUrl}/v1/corps`, { method: "OPTIONS" });
expect(res.status).toBe(204);
expect(res.headers.get("access-control-allow-methods")).toContain("GET");
const allowHeaders = res.headers.get("access-control-allow-headers") ?? "";
expect(allowHeaders).toContain("X-Seal-Corp");
// Advertises only headers a handler reads: the historic reserved session
// header was never consulted, and the openapi no longer claims otherwise.
expect(allowHeaders).not.toContain("X-Seal-Home-Session");
});
});