Skip to content

Cookie Expiration Age Fix #7327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions src/node/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ export const getCookieOptions = (req: express.Request): express.CookieOptions =>
// When logging in or out the request must include the href (the full current
// URL of that page) and the relative path to the root as given to it by the
// backend. Using these two we can determine the true absolute root.


function getConfigCookieMaxAgeAsMilliseconds(req: express.Request): number {
// the CLI flag or YAML key should be defined as "auth.cookie-max-age"
const days = Number(req.args["auth.cookie-max-age"] || 0)
return days * 24 * 60 * 60 * 1000
}


const url = new URL(
req.query.base || req.body?.base || "/",
req.query.href || req.body?.href || "http://" + (req.headers.host || "localhost"),
Expand All @@ -326,6 +335,7 @@ export const getCookieOptions = (req: express.Request): express.CookieOptions =>
domain: getCookieDomain(url.host, req.args["proxy-domain"]),
path: normalize(url.pathname) || "/",
sameSite: "lax",
maxAge: getConfigCookieMaxAgeAsMilliseconds(req) || 0,
}
}

Expand Down