fix(webui): send same-origin cookies with uploads
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
061b19afe1
commit
2732e2b3ce
3 files changed
+4
-3
No files matched your search
+1
-1
@@ -243,7 +243,7 @@ The upload path accepts the existing image, document, and video MIME whitelist.
|
||||
|
||||
Update WebUI and TUI together with the gateway. Existing messages and attachments remain available without a history migration. Clients must use HTTP uploads; `media.data_url` message uploads are no longer accepted. Local previews and the separate audio transcription protocol are unchanged.
|
||||
|
||||
Reverse proxies must forward `POST /api/attachments` (including its authorization header) to the gateway and permit the configured file sizes. Do not enable public CORS for this capability endpoint.
|
||||
Reverse proxies must forward `POST /api/attachments` (including its authorization header) to the gateway and permit the configured file sizes. Same-origin browser uploads include origin cookies for edge authentication; cross-origin uploads do not send cookies. Do not enable public CORS for this capability endpoint.
|
||||
|
||||
For a remote host opened through the local WebUI, update the local installation and the remote gateway together to use binary attachments. An older host's text chats and HTTP reads remain available.
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function uploadAttachments(
|
||||
if (!capability || !stillConnected()) throw new Error("Attachment upload connection is not ready");
|
||||
const url = new URL(capability.path, baseUrl.replace(/^ws:/, "http:").replace(/^wss:/, "https:"));
|
||||
if (!["http:", "https:"].includes(url.protocol)) throw new Error("HTTP upload is unavailable");
|
||||
// No handshake credentials in the URL, no redirects leaking the capability.
|
||||
// Send same-origin edge-auth cookies without following redirects with the capability.
|
||||
url.search = "";
|
||||
url.username = "";
|
||||
url.password = "";
|
||||
@@ -32,7 +32,7 @@ export async function uploadAttachments(
|
||||
const raw = atob(match[2]);
|
||||
const bytes = Uint8Array.from(raw, (character) => character.charCodeAt(0));
|
||||
const response = await fetch(url, {
|
||||
method: "POST", redirect: "error", credentials: "omit",
|
||||
method: "POST", redirect: "error", credentials: "same-origin",
|
||||
headers: {
|
||||
Authorization: `Bearer ${capability.token}`,
|
||||
"Content-Type": match[1],
|
||||
|
||||
@@ -2444,6 +2444,7 @@ describe("binary attachment transport", () => {
|
||||
expect(request.method).toBe("POST");
|
||||
expect(request.headers.Authorization).toBe("Bearer upload-capability");
|
||||
expect(request.redirect).toBe("error");
|
||||
expect(request.credentials).toBe("same-origin");
|
||||
expect(await request.body.text()).toBe(raw);
|
||||
const frame = socket.sent.find((value) => value.includes("opaque-ref"))!;
|
||||
expect(frame.length).toBeLessThan(1024);
|
||||
|
||||
Reference in new issue
Block a user