Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/frontend/__tests__/lib/requestSessionCsrf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ describe("getSessionFromRequest — CSRF origin check (B6)", () => {
expect(result).toEqual(validUser);
});

it("allows cookie session from the production custom domain when bearer auth is disabled", async () => {
mockState.getSession.mockResolvedValue(validUser);

const result = await getSessionFromRequest(
new Request("https://tokscale.ai/api/groups", {
method: "POST",
headers: {
Cookie: "tt_session=session-token",
Origin: "https://tokscale.ai",
},
}),
{ allowAuthorizationHeader: false }
);

expect(result).toEqual(validUser);
expect(mockState.getSession).toHaveBeenCalledTimes(1);
expect(mockState.getSessionFromHeader).not.toHaveBeenCalled();
});

it("rejects cookie session on mutating method with no Origin header (non-browser clients must use Bearer)", async () => {
mockState.getSession.mockResolvedValue(validUser);

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/lib/auth/requestSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function getAllowedOrigins(): string[] {
if (env) {
return env.split(",").map((o) => o.trim()).filter(Boolean);
}
return ["https://tokscale.dev", "http://localhost:3000"];
return ["https://tokscale.ai", "https://tokscale.dev", "http://localhost:3000"];
}

export async function getSessionFromRequest(
Expand Down