Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/backend/auth/cookie-names.ts
1447 views
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
import { basePathCookieName } from "@cocalc/util/misc";
17
18
const log = getLogger("cookie-names");
19
20
// Name of user provided remember_me cookie -- this is http-only and gets set
21
// when the user is signed in.
22
export const REMEMBER_ME_COOKIE_NAME =
23
process.env.COCALC_REMEMBER_ME_COOKIE_NAME ??
24
basePathCookieName({ basePath, name: "remember_me" });
25
26
log.debug("REMEMBER_ME_COOKIE_NAME", REMEMBER_ME_COOKIE_NAME);
27
28
// Name of user provided api key cookie, with appropriate base path.
29
// This is set by the user when using the api from node.js, especially
30
// via a websocket.
31
export const API_COOKIE_NAME = basePathCookieName({
32
basePath,
33
name: "api_key",
34
});
35
36
log.debug("API_COOKIE_NAME", API_COOKIE_NAME);
37
38
export const ACCOUNT_ID_COOKIE_NAME = basePathCookieName({
39
basePath,
40
name: "account_id",
41
});
42
43
export const PROJECT_SECRET_COOKIE_NAME = basePathCookieName({
44
basePath,
45
name: "project_secret",
46
});
47
48
export const PROJECT_ID_COOKIE_NAME = basePathCookieName({
49
basePath,
50
name: "project_id",
51
});
52
53
export const HUB_PASSWORD_COOKIE_NAME = basePathCookieName({
54
basePath,
55
name: "hub_password",
56
});
57
58