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
5 changes: 5 additions & 0 deletions .changeset/verify-apps-samesite-none.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"seamless-cli": patch
---

The verify reference apps now set `cookieSameSite: "none"` and name the React app in `allowedOrigins`, so they keep the conformance contract once the server adapters default to `SameSite=Lax` and refuse cross-origin requests without an allow-list.
8 changes: 7 additions & 1 deletion verify/adapter-app/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const { requireAuth, requirePermission } = seamless;
// on the host and reaches the API through a published port. See CONFORMANCE.md.
const ISSUER = process.env.AUTH_SERVER_ISSUER ?? process.env.AUTH_SERVER_URL;

const WEB_ORIGIN = process.env.WEB_ORIGIN ?? "http://localhost:5173";

const captured = new Map();
const ok = (channel) => ({ accepted: true, provider: "capture", channel });

Expand Down Expand Up @@ -42,7 +44,7 @@ app.set("trust proxy", 1);
// CORS must echo its origin and allow cookies. WEB_ORIGIN is the React app host.
app.use(
cors({
origin: process.env.WEB_ORIGIN ?? "http://localhost:5173",
origin: WEB_ORIGIN,
credentials: true,
}),
);
Expand Down Expand Up @@ -115,6 +117,10 @@ app.use(
authServerIssuer: ISSUER,
audience: ISSUER,
jwksKid: process.env.JWKS_KID,
// The contract pins SameSite=None, which is no longer the adapter default, and
// the React app is a different origin from this one, so it is named here.
cookieSameSite: "none",
allowedOrigins: [WEB_ORIGIN],
messaging: { handlers, defaults: { appName: "Seamless Verify" } },
}),
);
Expand Down
8 changes: 7 additions & 1 deletion verify/adapter-fastify-app/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const { requireAuth, requirePermission } = seamless;
// on the host and reaches the API through a published port. See CONFORMANCE.md.
const ISSUER = process.env.AUTH_SERVER_ISSUER ?? process.env.AUTH_SERVER_URL;

const WEB_ORIGIN = process.env.WEB_ORIGIN ?? "http://localhost:5173";

const captured = new Map();
const ok = (channel) => ({ accepted: true, provider: "capture", channel });

Expand Down Expand Up @@ -47,7 +49,7 @@ const app = Fastify({ trustProxy: (_address, hop) => hop < 1 });
// The React app (browser) calls the adapter cross-origin with credentials, so
// CORS must echo its origin and allow cookies. WEB_ORIGIN is the React app host.
await app.register(cors, {
origin: process.env.WEB_ORIGIN ?? "http://localhost:5173",
origin: WEB_ORIGIN,
credentials: true,
});

Expand Down Expand Up @@ -112,6 +114,10 @@ await app.register(seamlessAuth, {
authServerIssuer: ISSUER,
audience: ISSUER,
jwksKid: process.env.JWKS_KID,
// The contract pins SameSite=None, which is no longer the adapter default, and
// the React app is a different origin from this one, so it is named here.
cookieSameSite: "none",
allowedOrigins: [WEB_ORIGIN],
messaging: { handlers, defaults: { appName: "Seamless Verify" } },
});

Expand Down