From 62f8f8f1a7c6215229a57d3a884d17ec19ec40f4 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Mon, 10 Feb 2025 19:07:21 +0100 Subject: [PATCH] refactor(config): rename Cookies to Session as requested in PR #1155 --- config-sample.ini | 2 +- src/routes/csrf_protection.ts | 2 +- src/routes/session_parser.ts | 2 +- src/services/config.ts | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config-sample.ini b/config-sample.ini index 58d5c87ba..939eaa7a5 100644 --- a/config-sample.ini +++ b/config-sample.ini @@ -29,7 +29,7 @@ keyPath= trustedReverseProxy=false -[Cookies] +[Session] # Use this setting to constrain the current instance's "Path" value for the set cookies # This can be useful, when you have several instances running on the same domain, under different paths (e.g. by using a reverse proxy). # It prevents your instances from overwriting each others' cookies. diff --git a/src/routes/csrf_protection.ts b/src/routes/csrf_protection.ts index e9cd55f26..0ee03d467 100644 --- a/src/routes/csrf_protection.ts +++ b/src/routes/csrf_protection.ts @@ -6,7 +6,7 @@ import config from "../services/config.js"; const doubleCsrfUtilities = doubleCsrf({ getSecret: () => sessionSecret, cookieOptions: { - path: config.Cookies.cookiePath, + path: config.Session.cookiePath, secure: false, sameSite: "strict", httpOnly: !isElectron // set to false for Electron, see https://github.com/TriliumNext/Notes/pull/966 diff --git a/src/routes/session_parser.ts b/src/routes/session_parser.ts index b99882d0b..eaaf0ebe9 100644 --- a/src/routes/session_parser.ts +++ b/src/routes/session_parser.ts @@ -10,7 +10,7 @@ const sessionParser = session({ resave: false, // true forces the session to be saved back to the session store, even if the session was never modified during the request. saveUninitialized: false, // true forces a session that is "uninitialized" to be saved to the store. A session is uninitialized when it is new but not modified. cookie: { - path: config.Cookies.cookiePath, + path: config.Session.cookiePath, httpOnly: true, maxAge: 24 * 60 * 60 * 1000 // in milliseconds }, diff --git a/src/services/config.ts b/src/services/config.ts index 7dff7ad0a..b529d4792 100644 --- a/src/services/config.ts +++ b/src/services/config.ts @@ -32,7 +32,7 @@ export interface TriliumConfig { keyPath: string; trustedReverseProxy: boolean | string; }; - Cookies: { + Session: { cookiePath: string; } Sync: { @@ -79,9 +79,9 @@ const config: TriliumConfig = { process.env.TRILIUM_NETWORK_TRUSTEDREVERSEPROXY || iniConfig.Network.trustedReverseProxy || false }, - Cookies: { + Session: { cookiePath: - process.env.TRILIUM_COOKIES_COOKIEPATH || iniConfig?.Cookies?.cookiePath || "/" + process.env.TRILIUM_SESSION_COOKIEPATH || iniConfig?.Session?.cookiePath || "/" }, Sync: {