Skip to content

Commit

Permalink
Add sameSite attribute for auth cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Sep 25, 2022
1 parent 61a8230 commit 89a133e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/routes/auth/index.ts
Expand Up @@ -35,6 +35,7 @@ router.get("/redirect", auth(), async (ctx) => {

ctx.cookies.set("accessToken", jwtToken, {
httpOnly: false,
sameSite: true,
expires: addMonths(new Date(), 3),
});
const [team, collection, view] = await Promise.all([
Expand Down
2 changes: 2 additions & 0 deletions server/utils/authentication.ts
Expand Up @@ -74,6 +74,7 @@ export async function signIn(
// only used to display a UI hint for the user for next time
ctx.cookies.set("lastSignedIn", service, {
httpOnly: false,
sameSite: true,
expires: new Date("2100"),
domain,
});
Expand Down Expand Up @@ -101,6 +102,7 @@ export async function signIn(
ctx.redirect(`${team.url}/auth/redirect?token=${user.getTransferToken()}`);
} else {
ctx.cookies.set("accessToken", user.getJwtToken(), {
sameSite: true,
httpOnly: false,
expires,
});
Expand Down

0 comments on commit 89a133e

Please sign in to comment.