diff --git a/.changeset/verify-apps-samesite-none.md b/.changeset/verify-apps-samesite-none.md new file mode 100644 index 0000000..cd7d242 --- /dev/null +++ b/.changeset/verify-apps-samesite-none.md @@ -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. diff --git a/verify/adapter-app/server.mjs b/verify/adapter-app/server.mjs index 39bd19f..300cf94 100644 --- a/verify/adapter-app/server.mjs +++ b/verify/adapter-app/server.mjs @@ -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 }); @@ -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, }), ); @@ -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" } }, }), ); diff --git a/verify/adapter-fastify-app/server.mjs b/verify/adapter-fastify-app/server.mjs index bf190d6..c3b7dcc 100644 --- a/verify/adapter-fastify-app/server.mjs +++ b/verify/adapter-fastify-app/server.mjs @@ -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 }); @@ -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, }); @@ -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" } }, });