Skip to content

Commit

Permalink
Set auth cookies to be SameSite: lax (#1000)
Browse files Browse the repository at this point in the history
Since there are some cases where we are navigating from links, we need
to use `lax` as our SameSite.
  • Loading branch information
scotttrinh authored May 4, 2024
1 parent 7bfc054 commit d4a041f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/auth-express/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class ExpressAuth {
res.cookie(this.options.pkceVerifierCookieName, verifier, {
httpOnly: true,
path: "/",
sameSite: "strict",
sameSite: "lax",
expires,
secure: this.isSecure,
});
Expand All @@ -106,7 +106,7 @@ export class ExpressAuth {
res.cookie(this.options.authCookieName, authToken, {
httpOnly: true,
path: "/",
sameSite: "strict",
sameSite: "lax",
expires: expires ?? undefined,
secure: this.isSecure,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-nextjs/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export abstract class NextAuth extends NextAuthHelpers {
value: verifier,
httpOnly: true,
path: "/",
sameSite: "strict",
sameSite: "lax",
secure: this.isSecure,
expires: Date.now() + 1000 * 60 * 60 * 24 * 7, // In 7 days
});
Expand All @@ -128,7 +128,7 @@ export abstract class NextAuth extends NextAuthHelpers {
name: this.options.authCookieName,
value: token,
httpOnly: true,
sameSite: "strict",
sameSite: "lax",
path: "/",
secure: this.isSecure,
expires: expirationDate ?? undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-remix/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class RemixServerAuth extends RemixClientAuth {
const expires = new Date(Date.now() + 1000 * 60 * 24 * 7); // In 7 days
return cookie.serialize(this.options.pkceVerifierCookieName, verifier, {
httpOnly: true,
sameSite: "strict",
sameSite: "lax",
path: "/",
expires,
secure: this.isSecure,
Expand All @@ -138,7 +138,7 @@ export class RemixServerAuth extends RemixClientAuth {
const expires = Auth.getTokenExpiration(authToken);
return cookie.serialize(this.options.authCookieName, authToken, {
httpOnly: true,
sameSite: "strict",
sameSite: "lax",
path: "/",
expires: expires ?? undefined,
secure: this.isSecure,
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-sveltekit/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class ServerRequestAuth extends ClientAuth {
const expires = new Date(Date.now() + 1000 * 60 * 24 * 7); // In 7 days
this.cookies.set(this.config.pkceVerifierCookieName, verifier, {
httpOnly: true,
sameSite: "strict",
sameSite: "lax",
path: "/",
expires,
secure: this.isSecure,
Expand All @@ -147,7 +147,7 @@ export class ServerRequestAuth extends ClientAuth {
const expires = Auth.getTokenExpiration(authToken);
this.cookies.set(this.config.authCookieName, authToken, {
httpOnly: true,
sameSite: "strict",
sameSite: "lax",
path: "/",
expires: expires ?? undefined,
secure: this.isSecure,
Expand Down

0 comments on commit d4a041f

Please sign in to comment.