diff --git a/src/contracts/rest-profiles.ts b/src/contracts/rest-profiles.ts index 1bbdfd8c..ea7e9af1 100644 --- a/src/contracts/rest-profiles.ts +++ b/src/contracts/rest-profiles.ts @@ -20,10 +20,15 @@ export type RestProviderProfile = Readonly<{ * VD-23. The complete closed set of headers a credential owner may contribute. * Transport-owned headers (`accept`, `content-type`, `idempotency-key`) and * every forbidden request header are deliberately absent. + * + * `x-xsrf-token` is the paired backend's default CSRF header (Spring + * `CookieCsrfTokenRepository`, `APP_SESSION_CSRF_HEADER_NAME`). A profile + * still has to name it in its own allowed set before a provider may send it. */ export const CREDENTIAL_HEADER_NAMES = Object.freeze([ "authorization", "x-csrf-token", + "x-xsrf-token", "x-tenant-context", ] as const); diff --git a/tests/unit/product-composition-fixture.test.ts b/tests/unit/product-composition-fixture.test.ts index fac1d988..0088f31f 100644 --- a/tests/unit/product-composition-fixture.test.ts +++ b/tests/unit/product-composition-fixture.test.ts @@ -65,7 +65,7 @@ vi.mock("../../src/contracts/product-contracts.ts", async () => { const { z } = await import("../../src/contracts/zod.ts"); const cookieProfile = ( authProfileId: string, - header: readonly "x-csrf-token"[], + header: readonly ("x-csrf-token" | "x-xsrf-token")[], ) => Object.freeze({ authProfileId, @@ -80,7 +80,8 @@ vi.mock("../../src/contracts/product-contracts.ts", async () => { }), PRODUCT_REST_AUTH_PROFILES: Object.freeze({ MEMENTO_BFF_READ: cookieProfile("MEMENTO_BFF_READ", []), - MEMENTO_BFF_WRITE: cookieProfile("MEMENTO_BFF_WRITE", ["x-csrf-token"]), + // The paired backend's default CSRF header (Spring CookieCsrfTokenRepository). + MEMENTO_BFF_WRITE: cookieProfile("MEMENTO_BFF_WRITE", ["x-xsrf-token"]), TECH_LOG_STUDIO_BOOTSTRAP: cookieProfile("TECH_LOG_STUDIO_BOOTSTRAP", []), TECH_LOG_STUDIO_SESSION: cookieProfile("TECH_LOG_STUDIO_SESSION", ["x-csrf-token"]), }), @@ -175,7 +176,7 @@ vi.mock("../../src/bootstrap/product-composition.ts", async () => { const token = context.readCookie("XSRF-TOKEN"); return token === undefined ? { kind: "UNAVAILABLE" as const } - : { kind: "READY" as const, headers: { "x-csrf-token": token } }; + : { kind: "READY" as const, headers: { "x-xsrf-token": token } }; }, // tech-log Studio: the token's own issuing call carries none. TECH_LOG_STUDIO_BOOTSTRAP: () => ({ kind: "READY" as const, headers: {} }), @@ -357,7 +358,7 @@ describe("09-02 product needs through the product-owned files only", () => { expect(outcome.kind).toBe("SUCCESS"); expect(sent(fetcher, 0).credentials).toBe("include"); - expect([...sent(fetcher, 0).headers.keys()]).not.toContain("x-csrf-token"); + expect([...sent(fetcher, 0).headers.keys()]).not.toContain("x-xsrf-token"); }); it("memento: BFF writes carry the XSRF cookie and fail closed without it", async () => { @@ -365,7 +366,7 @@ describe("09-02 product needs through the product-owned files only", () => { await expect( withCookie.http.execute(list(OPERATIONS.bffWrite), { limit: 1 }, { routeId: "R" }), ).resolves.toMatchObject({ kind: "SUCCESS" }); - expect(sent(withCookie.fetcher, 0).headers.get("x-csrf-token")).toBe("xsrf-1"); + expect(sent(withCookie.fetcher, 0).headers.get("x-xsrf-token")).toBe("xsrf-1"); current?.infrastructure.dispose(); const without = await compose();