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
4 changes: 3 additions & 1 deletion app/(authenticated)/link/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { applicationOrigin } from "@shared/environment/origin";

export const metadata = {
title: "Link wallet",
referrer: "no-referrer" as const,
// Native form POSTs need their Origin header for the route's CSRF check.
// Cross-origin navigations still receive no referrer.
referrer: "same-origin" as const,
};

export default async function Page({ searchParams }: PageProps<"/link">) {
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,16 @@ describe("Link wallet integration", () => {
const denied = request();
denied.headers.set("origin", "https://attacker.example");
expect((await POST(denied)).status).toBe(403);
const opaqueOrigin = request();
opaqueOrigin.headers.set("origin", "null");
expect((await POST(opaqueOrigin)).status).toBe(403);
const missingOrigin = request();
missingOrigin.headers.delete("origin");
expect((await POST(missingOrigin)).status).toBe(403);

const started = await POST(request());
expect(started.status).toBe(303);
expect(started.headers.get("referrer-policy")).toBe("no-referrer");
const destination = new URL(started.headers.get("location") ?? "");
expect(destination.origin).toBe("https://login.link.com");
expect(destination.searchParams.get("redirect_uri")).toBe(
Expand Down
Loading