Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Security: visitors don't see the install's AI setup on the Assist page

Adarshd33139fdddf0
diff --git a/src/app/api/assist/route.ts b/src/app/api/assist/route.ts
index 90a96e19..ed8d1e21 100644
--- a/src/app/api/assist/route.ts
+++ b/src/app/api/assist/route.ts
@@ -13,13 +13,15 @@ const Create = AssistMessage.extend({
/**
* Chats (all, `?project=<id>`, or `?project=none` for chats outside projects; `?q=` searches), with what can run.
- * A guest's or an account's list (GUEST_HEADER) is empty: the chats are the owner's.
+ * A guest's or an account's answer (GUEST_HEADER) is an empty list and nothing else: the chats, and the install's AI
+ * setup (which providers have keys, the local server and its models, a free plan's use), are the owner's.
*/
export async function GET(request: Request) {
await connection();
+ if (isGuest(request)) return Response.json({ threads: [] });
const sp = new URL(request.url).searchParams;
const project = sp.get("project");
- const threads = isGuest(request) ? [] : listThreads({ project: project === "none" ? null : (project ?? undefined), q: sp.get("q") ?? undefined });
+ const threads = listThreads({ project: project === "none" ? null : (project ?? undefined), q: sp.get("q") ?? undefined });
const [agent, can] = await Promise.all([resolveAgent(), availability()]);
return Response.json({ threads, agent, availability: can });
}
diff --git a/src/components/assist/hooks.ts b/src/components/assist/hooks.ts
index 8e58adf5..9cf2b503 100644
--- a/src/components/assist/hooks.ts
+++ b/src/components/assist/hooks.ts
@@ -58,8 +58,9 @@ const send = async <T,>(url: string, method: string, body?: unknown) =>
export interface ChatList {
threads: AssistThreadSummary[];
- agent: AssistThread["agent"];
- availability: AssistAvailability;
+ /** Left out for a visitor (public sign-up): the install's AI setup is the owner's. */
+ agent?: AssistThread["agent"];
+ availability?: AssistAvailability;
}
/** Chats, optionally one project's (or "none": chats outside projects), with a search. */
diff --git a/tests/public-signup-visitors.test.ts b/tests/public-signup-visitors.test.ts
index 84b70504..5d935e84 100644
--- a/tests/public-signup-visitors.test.ts
+++ b/tests/public-signup-visitors.test.ts
@@ -158,6 +158,16 @@ describe("Assist is the owner's", () => {
for (const [method, p] of changes) expect(passed(proxy(req(p, { method, cookie: owner }))), `${method} ${p}`).toBe(true);
});
+ it("shows a visitor an empty chat list and nothing of the install's AI setup", async () => {
+ for (const cookie of [undefined, account]) expect(toldGuest(proxy(req("/api/assist", { cookie })))).toBe(true);
+ const { GET } = await import("@/app/api/assist/route");
+ const visitor = await (await GET(new Request("http://localhost:3000/api/assist", { headers: { [access.GUEST_HEADER]: "1" } }))).json();
+ expect(visitor).toEqual({ threads: [] });
+ const own = await (await GET(new Request("http://localhost:3000/api/assist"))).json();
+ expect(own).toHaveProperty("availability");
+ expect(own).toHaveProperty("agent");
+ });
+
it("says an owner-only read is the owner's to see", async () => {
expect((await proxy(req("/api/assist/connectors", { cookie: account })).json()).error).toMatch(/aren't part of your account/);
expect((await proxy(req("/api/assist/connectors", { method: "POST", cookie: account })).json()).error).toMatch(/aren't part of your account/);