chore: Use httpOnly authentication cookie (#5552)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { subHours } from "date-fns";
|
||||
import { subHours, subMinutes } from "date-fns";
|
||||
import Router from "koa-router";
|
||||
import { uniqBy } from "lodash";
|
||||
import { TeamPreference } from "@shared/types";
|
||||
import { parseDomain } from "@shared/utils/domains";
|
||||
import { getCookieDomain, parseDomain } from "@shared/utils/domains";
|
||||
import env from "@server/env";
|
||||
import auth from "@server/middlewares/authentication";
|
||||
import { transaction } from "@server/middlewares/transaction";
|
||||
@@ -139,6 +139,7 @@ router.post("auth.info", auth(), async (ctx: APIContext<T.AuthInfoReq>) => {
|
||||
includeDetails: true,
|
||||
}),
|
||||
team: presentTeam(team),
|
||||
collaborationToken: user.getCollaborationToken(),
|
||||
availableTeams: uniqBy([...signedInTeams, ...availableTeams], "id").map(
|
||||
(team) =>
|
||||
presentAvailableTeam(
|
||||
@@ -176,6 +177,11 @@ router.post(
|
||||
}
|
||||
);
|
||||
|
||||
ctx.cookies.set("accessToken", "", {
|
||||
expires: subMinutes(new Date(), 1),
|
||||
domain: getCookieDomain(ctx.hostname),
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
success: true,
|
||||
};
|
||||
|
||||
@@ -32,7 +32,6 @@ router.get("/redirect", auth(), async (ctx: APIContext) => {
|
||||
await user.updateActiveAt(ctx, true);
|
||||
|
||||
ctx.cookies.set("accessToken", jwtToken, {
|
||||
httpOnly: false,
|
||||
sameSite: "lax",
|
||||
expires: addMonths(new Date(), 3),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user