Tighten the remaining Cards and dev server security defaults
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 19m52s
Validate and deploy Sokko G / deploy (push) Successful in 10s

Session and OAuth cookies now carry the __Host- prefix over HTTPS, so another
application of the domain cannot set them. The public configuration route has
a request limit, the trader list reads every player in one query, and new
campaign codes need eight characters while existing ones keep working.

The Vite server now listens on 127.0.0.1 unless HOST says otherwise, because
it gives administrator rights to any visitor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-06 14:27:22 +01:00
parent 9b6da88ed3
commit 9ce0c3e33a
9 changed files with 137 additions and 43 deletions

View file

@ -1299,14 +1299,14 @@ test("administrator navigates sections, manages mythic content and previews visu
await expect(campaignForm.getByLabel("Sans date d’expiration")).toBeChecked();
await expect(campaignForm.getByLabel("Valable jusqu’au")).toHaveCount(0);
await campaignForm.getByRole("button", { name: "Générer" }).click();
await expect(campaignForm.getByLabel("Code à annoncer (4 à 24 caractères)")).toHaveValue(/^[2-9A-HJKMNP-Z]{4}-[2-9A-HJKMNP-Z]{4}$/);
await campaignForm.getByLabel("Code à annoncer (4 à 24 caractères)").fill("dragon");
await expect(campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)")).toHaveValue(/^[2-9A-HJKMNP-Z]{4}-[2-9A-HJKMNP-Z]{4}$/);
await campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)").fill("dragon-01");
await campaignForm.getByLabel("Sans limite d’utilisations").uncheck();
await campaignForm.getByLabel("Utilisations maximum").fill("1");
await campaignForm.getByLabel("Sans date d’expiration").uncheck();
await expect(campaignForm.getByLabel("Valable jusqu’au")).toBeVisible();
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Carte Dragon du Néant Étoilé (Mythique · Prisme spectral — Aurore)");
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Le code DRAGON, utilisable 1 fois, jusqu’au");
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Le code DRAGON-01, utilisable 1 fois, jusqu’au");
await createButton.click();
const generated = page.locator(".nebula-admin-generated");
await expect(generated.getByRole("heading", { name: "Campagne « Cadeau dragon » créée" })).toBeVisible();
@ -1328,8 +1328,8 @@ test("administrator navigates sections, manages mythic content and previews visu
await packItem.getByLabel("Quantité").fill("2");
await packItem.getByRole("radio", { name: "Une rareté minimum" }).click();
await chooseOption(packItem, "Rareté garantie", "Légendaire");
await campaignForm.getByLabel("Code à annoncer (4 à 24 caractères)").fill("e2e live");
await expect(campaignForm.getByLabel("Code à annoncer (4 à 24 caractères)")).toHaveValue("E2E-LIVE");
await campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)").fill("e2e live");
await expect(campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)")).toHaveValue("E2E-LIVE");
await expect(campaignForm.locator(".nebula-admin-campaign-missing")).toHaveCount(0);
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("+ 2 × Paquet Genèse Astrale · au moins 1 carte légendaire ou mieux garantie");
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Le code E2E-LIVE, utilisable sans limite, sans date d’expiration.");
@ -1384,7 +1384,7 @@ test("players give cards and answer trade proposals from two accounts", async ({
const { token } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-partner.json"), "utf8"));
const partnerContext = await browser.newContext({ baseURL: "http://127.0.0.1:4180" });
await partnerContext.addCookies([{ name: "sokkog_cards_session", value: token, url: "http://127.0.0.1:4180" }]);
await partnerContext.addCookies([{ name: "__Host-sokkog_cards_session", value: token, domain: "127.0.0.1", path: "/", secure: true, httpOnly: true, sameSite: "Lax" }]);
const partner = await partnerContext.newPage();
await partner.goto("/#/cards/transfers");
@ -1553,8 +1553,10 @@ test("a player reads the privacy notice and deletes the account for good", async
const { token } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-partner.json"), "utf8"));
const partnerContext = await browser.newContext({ baseURL: "http://127.0.0.1:4180" });
await partnerContext.addCookies([{ name: "sokkog_cards_session", value: token, url: "http://127.0.0.1:4180" }]);
const { traders } = await (await partnerContext.request.get("/api/cards/traders")).json();
await partnerContext.addCookies([{ name: "__Host-sokkog_cards_session", value: token, domain: "127.0.0.1", path: "/", secure: true, httpOnly: true, sameSite: "Lax" }]);
const partnerPage = await partnerContext.newPage();
await partnerPage.goto("http://127.0.0.1:4180/");
const { traders } = await partnerPage.evaluate(() => globalThis.fetch("/api/cards/traders").then((response) => response.json()));
expect(traders.map((trader) => trader.displayName)).not.toContain("Version développement");
await partnerContext.close();