CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/backend/auth/cookie-names.ts
Views: 687
1
/*
2
We prefix the cookie with the base path so that it's possible to
3
have multiple distinct cocalc servers running on the same domain
4
without them colliding when doing development. However, this doesn't
5
help with multiple cocalc's on the same server with the same base
6
path serving on distinct ports. In that case, you can explicitly
7
set the remember me cookie name to whatever you want by
8
setting the following environment variable:
9
10
- COCALC_REMEMBER_ME_COOKIE_NAME -- env variable for arbitrary remember_me cookie name
11
- COCALC_API_COOKIE_NAME -- similar for the api cookie name.
12
*/
13
14
import basePath from "@cocalc/backend/base-path";
15
import getLogger from "@cocalc/backend/logger";
16
17
const log = getLogger("cookie-names");
18
19
// Name of user provided remember_me cookie -- this is http-only and gets set
20
// when the user is signed in.
21
export const REMEMBER_ME_COOKIE_NAME =
22
process.env.COCALC_REMEMBER_ME_COOKIE_NAME ??
23
`${basePath.length <= 1 ? "" : encodeURIComponent(basePath)}remember_me`;
24
25
log.debug("REMEMBER_ME_COOKIE_NAME", REMEMBER_ME_COOKIE_NAME);
26
27
// Name of user provided api key cookie, with appropriate base path.
28
// This is set by the user when using the api from node.js, especially
29
// via a websocket.
30
export const API_COOKIE_NAME =
31
process.env.COCALC_API_COOKIE_NAME ??
32
`${basePath.length <= 1 ? "" : encodeURIComponent(basePath)}api_key`;
33
34
log.debug("API_COOKIE_NAME", API_COOKIE_NAME);
35
36