Path: blob/master/src/packages/backend/auth/cookie-names.ts
1447 views
/*1We prefix the cookie with the base path so that it's possible to2have multiple distinct cocalc servers running on the same domain3without them colliding when doing development. However, this doesn't4help with multiple cocalc's on the same server with the same base5path serving on distinct ports. In that case, you can explicitly6set the remember me cookie name to whatever you want by7setting the following environment variable:89- COCALC_REMEMBER_ME_COOKIE_NAME -- env variable for arbitrary remember_me cookie name10- COCALC_API_COOKIE_NAME -- similar for the api cookie name.11*/1213import basePath from "@cocalc/backend/base-path";14import getLogger from "@cocalc/backend/logger";15import { basePathCookieName } from "@cocalc/util/misc";1617const log = getLogger("cookie-names");1819// Name of user provided remember_me cookie -- this is http-only and gets set20// when the user is signed in.21export const REMEMBER_ME_COOKIE_NAME =22process.env.COCALC_REMEMBER_ME_COOKIE_NAME ??23basePathCookieName({ basePath, name: "remember_me" });2425log.debug("REMEMBER_ME_COOKIE_NAME", REMEMBER_ME_COOKIE_NAME);2627// 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, especially29// via a websocket.30export const API_COOKIE_NAME = basePathCookieName({31basePath,32name: "api_key",33});3435log.debug("API_COOKIE_NAME", API_COOKIE_NAME);3637export const ACCOUNT_ID_COOKIE_NAME = basePathCookieName({38basePath,39name: "account_id",40});4142export const PROJECT_SECRET_COOKIE_NAME = basePathCookieName({43basePath,44name: "project_secret",45});4647export const PROJECT_ID_COOKIE_NAME = basePathCookieName({48basePath,49name: "project_id",50});5152export const HUB_PASSWORD_COOKIE_NAME = basePathCookieName({53basePath,54name: "hub_password",55});565758