settings.defaults.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  1. const fs = require('fs')
  2. const Path = require('path')
  3. const { merge } = require('@overleaf/settings/merge')
  4. // Automatically detect module imports that are included in this version of the application (SaaS, Server-CE, Server Pro).
  5. // E.g. during a Server-CE build, we will not find imports for proprietary modules.
  6. //
  7. // Restart webpack after adding/removing modules.
  8. const MODULES_PATH = Path.join(__dirname, '../modules')
  9. const entryPointsIde = []
  10. const entryPointsMain = []
  11. fs.readdirSync(MODULES_PATH).forEach(module => {
  12. const entryPathIde = Path.join(
  13. MODULES_PATH,
  14. module,
  15. '/frontend/js/ide/index.js'
  16. )
  17. if (fs.existsSync(entryPathIde)) {
  18. entryPointsIde.push(entryPathIde)
  19. }
  20. const entryPathMain = Path.join(
  21. MODULES_PATH,
  22. module,
  23. '/frontend/js/main/index.js'
  24. )
  25. if (fs.existsSync(entryPathMain)) {
  26. entryPointsMain.push(entryPathMain)
  27. }
  28. })
  29. let defaultFeatures, siteUrl
  30. // Make time interval config easier.
  31. const seconds = 1000
  32. const minutes = 60 * seconds
  33. // These credentials are used for authenticating api requests
  34. // between services that may need to go over public channels
  35. const httpAuthUser = process.env.WEB_API_USER
  36. const httpAuthPass = process.env.WEB_API_PASSWORD
  37. const httpAuthUsers = {}
  38. if (httpAuthUser && httpAuthPass) {
  39. httpAuthUsers[httpAuthUser] = httpAuthPass
  40. }
  41. const intFromEnv = function (name, defaultValue) {
  42. if (
  43. [null, undefined].includes(defaultValue) ||
  44. typeof defaultValue !== 'number'
  45. ) {
  46. throw new Error(
  47. `Bad default integer value for setting: ${name}, ${defaultValue}`
  48. )
  49. }
  50. return parseInt(process.env[name], 10) || defaultValue
  51. }
  52. const defaultTextExtensions = [
  53. 'tex',
  54. 'latex',
  55. 'sty',
  56. 'cls',
  57. 'bst',
  58. 'bib',
  59. 'bibtex',
  60. 'txt',
  61. 'tikz',
  62. 'mtx',
  63. 'rtex',
  64. 'md',
  65. 'asy',
  66. 'lbx',
  67. 'bbx',
  68. 'cbx',
  69. 'm',
  70. 'lco',
  71. 'dtx',
  72. 'ins',
  73. 'ist',
  74. 'def',
  75. 'clo',
  76. 'ldf',
  77. 'rmd',
  78. 'lua',
  79. 'gv',
  80. 'mf',
  81. 'yml',
  82. 'yaml',
  83. 'lhs',
  84. 'mk',
  85. 'xmpdata',
  86. 'cfg',
  87. 'rnw',
  88. 'ltx',
  89. 'inc',
  90. ]
  91. const parseTextExtensions = function (extensions) {
  92. if (extensions) {
  93. return extensions.split(',').map(ext => ext.trim())
  94. } else {
  95. return []
  96. }
  97. }
  98. const httpPermissionsPolicy = {
  99. blocked: [
  100. 'accelerometer',
  101. 'attribution-reporting',
  102. 'browsing-topics',
  103. 'camera',
  104. 'display-capture',
  105. 'encrypted-media',
  106. 'fullscreen',
  107. 'gamepad',
  108. 'geolocation',
  109. 'gyroscope',
  110. 'hid',
  111. 'identity-credentials-get',
  112. 'idle-detection',
  113. 'local-fonts',
  114. 'magnetometer',
  115. 'microphone',
  116. 'midi',
  117. 'otp-credentials',
  118. 'payment',
  119. 'picture-in-picture',
  120. 'screen-wake-lock',
  121. 'serial',
  122. 'storage-access',
  123. 'usb',
  124. 'window-management',
  125. 'xr-spatial-tracking',
  126. ],
  127. allowed: {
  128. autoplay: 'self "https://videos.ctfassets.net"',
  129. },
  130. }
  131. module.exports = {
  132. env: 'server-ce',
  133. limits: {
  134. httpGlobalAgentMaxSockets: 300,
  135. httpsGlobalAgentMaxSockets: 300,
  136. },
  137. allowAnonymousReadAndWriteSharing:
  138. process.env.OVERLEAF_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING === 'true',
  139. // Databases
  140. // ---------
  141. mongo: {
  142. options: {
  143. appname: 'web',
  144. maxPoolSize: parseInt(process.env.MONGO_POOL_SIZE, 10) || 100,
  145. serverSelectionTimeoutMS:
  146. parseInt(process.env.MONGO_SERVER_SELECTION_TIMEOUT, 10) || 60000,
  147. // Setting socketTimeoutMS to 0 means no timeout
  148. socketTimeoutMS: parseInt(
  149. process.env.MONGO_SOCKET_TIMEOUT ?? '60000',
  150. 10
  151. ),
  152. monitorCommands: true,
  153. },
  154. url:
  155. process.env.MONGO_CONNECTION_STRING ||
  156. process.env.MONGO_URL ||
  157. `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`,
  158. hasSecondaries: process.env.MONGO_HAS_SECONDARIES === 'true',
  159. },
  160. redis: {
  161. web: {
  162. host: process.env.REDIS_HOST || '127.0.0.1',
  163. port: process.env.REDIS_PORT || '6379',
  164. password: process.env.REDIS_PASSWORD || '',
  165. db: process.env.REDIS_DB,
  166. maxRetriesPerRequest: parseInt(
  167. process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
  168. ),
  169. },
  170. // websessions:
  171. // cluster: [
  172. // {host: '127.0.0.1', port: 7000}
  173. // {host: '127.0.0.1', port: 7001}
  174. // {host: '127.0.0.1', port: 7002}
  175. // {host: '127.0.0.1', port: 7003}
  176. // {host: '127.0.0.1', port: 7004}
  177. // {host: '127.0.0.1', port: 7005}
  178. // ]
  179. // ratelimiter:
  180. // cluster: [
  181. // {host: '127.0.0.1', port: 7000}
  182. // {host: '127.0.0.1', port: 7001}
  183. // {host: '127.0.0.1', port: 7002}
  184. // {host: '127.0.0.1', port: 7003}
  185. // {host: '127.0.0.1', port: 7004}
  186. // {host: '127.0.0.1', port: 7005}
  187. // ]
  188. // cooldown:
  189. // cluster: [
  190. // {host: '127.0.0.1', port: 7000}
  191. // {host: '127.0.0.1', port: 7001}
  192. // {host: '127.0.0.1', port: 7002}
  193. // {host: '127.0.0.1', port: 7003}
  194. // {host: '127.0.0.1', port: 7004}
  195. // {host: '127.0.0.1', port: 7005}
  196. // ]
  197. api: {
  198. host: process.env.REDIS_HOST || '127.0.0.1',
  199. port: process.env.REDIS_PORT || '6379',
  200. password: process.env.REDIS_PASSWORD || '',
  201. maxRetriesPerRequest: parseInt(
  202. process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
  203. ),
  204. },
  205. },
  206. // Service locations
  207. // -----------------
  208. // Configure which ports to run each service on. Generally you
  209. // can leave these as they are unless you have some other services
  210. // running which conflict, or want to run the web process on port 80.
  211. internal: {
  212. web: {
  213. port: process.env.WEB_PORT || 3000,
  214. host: process.env.LISTEN_ADDRESS || '127.0.0.1',
  215. },
  216. },
  217. // Tell each service where to find the other services. If everything
  218. // is running locally then this is easy, but they exist as separate config
  219. // options incase you want to run some services on remote hosts.
  220. apis: {
  221. web: {
  222. url: `http://${
  223. process.env.WEB_API_HOST || process.env.WEB_HOST || '127.0.0.1'
  224. }:${process.env.WEB_API_PORT || process.env.WEB_PORT || 3000}`,
  225. user: httpAuthUser,
  226. pass: httpAuthPass,
  227. },
  228. documentupdater: {
  229. url: `http://${
  230. process.env.DOCUPDATER_HOST ||
  231. process.env.DOCUMENT_UPDATER_HOST ||
  232. '127.0.0.1'
  233. }:3003`,
  234. },
  235. spelling: {
  236. url: `http://${process.env.SPELLING_HOST || '127.0.0.1'}:3005`,
  237. host: process.env.SPELLING_HOST,
  238. },
  239. docstore: {
  240. url: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`,
  241. pubUrl: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`,
  242. },
  243. chat: {
  244. internal_url: `http://${process.env.CHAT_HOST || '127.0.0.1'}:3010`,
  245. },
  246. filestore: {
  247. url: `http://${process.env.FILESTORE_HOST || '127.0.0.1'}:3009`,
  248. },
  249. clsi: {
  250. url: `http://${process.env.CLSI_HOST || '127.0.0.1'}:3013`,
  251. // url: "http://#{process.env['CLSI_LB_HOST']}:3014"
  252. backendGroupName: undefined,
  253. submissionBackendClass:
  254. process.env.CLSI_SUBMISSION_BACKEND_CLASS || 'n2d',
  255. },
  256. project_history: {
  257. sendProjectStructureOps: true,
  258. url: `http://${process.env.PROJECT_HISTORY_HOST || '127.0.0.1'}:3054`,
  259. },
  260. realTime: {
  261. url: `http://${process.env.REALTIME_HOST || '127.0.0.1'}:3026`,
  262. },
  263. contacts: {
  264. url: `http://${process.env.CONTACTS_HOST || '127.0.0.1'}:3036`,
  265. },
  266. notifications: {
  267. url: `http://${process.env.NOTIFICATIONS_HOST || '127.0.0.1'}:3042`,
  268. },
  269. webpack: {
  270. url: `http://${process.env.WEBPACK_HOST || '127.0.0.1'}:3808`,
  271. },
  272. wiki: {
  273. url: process.env.WIKI_URL || 'https://learn.sharelatex.com',
  274. maxCacheAge: parseInt(process.env.WIKI_MAX_CACHE_AGE || 5 * minutes, 10),
  275. },
  276. haveIBeenPwned: {
  277. enabled: process.env.HAVE_I_BEEN_PWNED_ENABLED === 'true',
  278. url:
  279. process.env.HAVE_I_BEEN_PWNED_URL || 'https://api.pwnedpasswords.com',
  280. timeout: parseInt(process.env.HAVE_I_BEEN_PWNED_TIMEOUT, 10) || 5 * 1000,
  281. },
  282. // For legacy reasons, we need to populate the below objects.
  283. v1: {},
  284. recurly: {},
  285. },
  286. // Defines which features are allowed in the
  287. // Permissions-Policy HTTP header
  288. httpPermissions: httpPermissionsPolicy,
  289. useHttpPermissionsPolicy: true,
  290. jwt: {
  291. key: process.env.OT_JWT_AUTH_KEY,
  292. algorithm: process.env.OT_JWT_AUTH_ALG || 'HS256',
  293. },
  294. devToolbar: {
  295. enabled: false,
  296. },
  297. splitTests: [],
  298. // Where your instance of Overleaf Community Edition/Server Pro can be found publicly. Used in emails
  299. // that are sent out, generated links, etc.
  300. siteUrl: (siteUrl = process.env.PUBLIC_URL || 'http://127.0.0.1:3000'),
  301. lockManager: {
  302. lockTestInterval: intFromEnv('LOCK_MANAGER_LOCK_TEST_INTERVAL', 50),
  303. maxTestInterval: intFromEnv('LOCK_MANAGER_MAX_TEST_INTERVAL', 1000),
  304. maxLockWaitTime: intFromEnv('LOCK_MANAGER_MAX_LOCK_WAIT_TIME', 10000),
  305. redisLockExpiry: intFromEnv('LOCK_MANAGER_REDIS_LOCK_EXPIRY', 30),
  306. slowExecutionThreshold: intFromEnv(
  307. 'LOCK_MANAGER_SLOW_EXECUTION_THRESHOLD',
  308. 5000
  309. ),
  310. },
  311. // Optional separate location for websocket connections, if unset defaults to siteUrl.
  312. wsUrl: process.env.WEBSOCKET_URL,
  313. wsUrlV2: process.env.WEBSOCKET_URL_V2,
  314. wsUrlBeta: process.env.WEBSOCKET_URL_BETA,
  315. wsUrlV2Percentage: parseInt(
  316. process.env.WEBSOCKET_URL_V2_PERCENTAGE || '0',
  317. 10
  318. ),
  319. wsRetryHandshake: parseInt(process.env.WEBSOCKET_RETRY_HANDSHAKE || '5', 10),
  320. // cookie domain
  321. // use full domain for cookies to only be accessible from that domain,
  322. // replace subdomain with dot to have them accessible on all subdomains
  323. cookieDomain: process.env.COOKIE_DOMAIN,
  324. cookieName: process.env.COOKIE_NAME || 'overleaf.sid',
  325. cookieRollingSession: true,
  326. // this is only used if cookies are used for clsi backend
  327. // clsiCookieKey: "clsiserver"
  328. robotsNoindex: process.env.ROBOTS_NOINDEX === 'true' || false,
  329. maxEntitiesPerProject: parseInt(
  330. process.env.MAX_ENTITIES_PER_PROJECT || '2000',
  331. 10
  332. ),
  333. projectUploadTimeout: parseInt(
  334. process.env.PROJECT_UPLOAD_TIMEOUT || '120000',
  335. 10
  336. ),
  337. maxUploadSize: 50 * 1024 * 1024, // 50 MB
  338. multerOptions: {
  339. preservePath: process.env.MULTER_PRESERVE_PATH,
  340. },
  341. // start failing the health check if active handles exceeds this limit
  342. maxActiveHandles: process.env.MAX_ACTIVE_HANDLES
  343. ? parseInt(process.env.MAX_ACTIVE_HANDLES, 10)
  344. : undefined,
  345. // Security
  346. // --------
  347. security: {
  348. sessionSecret: process.env.SESSION_SECRET,
  349. sessionSecretUpcoming: process.env.SESSION_SECRET_UPCOMING,
  350. sessionSecretFallback: process.env.SESSION_SECRET_FALLBACK,
  351. bcryptRounds: parseInt(process.env.BCRYPT_ROUNDS, 10) || 12,
  352. }, // number of rounds used to hash user passwords (raised to power 2)
  353. adminUrl: process.env.ADMIN_URL,
  354. adminOnlyLogin: process.env.ADMIN_ONLY_LOGIN === 'true',
  355. adminPrivilegeAvailable: process.env.ADMIN_PRIVILEGE_AVAILABLE === 'true',
  356. blockCrossOriginRequests: process.env.BLOCK_CROSS_ORIGIN_REQUESTS === 'true',
  357. allowedOrigins: (process.env.ALLOWED_ORIGINS || siteUrl).split(','),
  358. httpAuthUsers,
  359. // Default features
  360. // ----------------
  361. //
  362. // You can select the features that are enabled by default for new
  363. // new users.
  364. defaultFeatures: (defaultFeatures = {
  365. collaborators: -1,
  366. dropbox: true,
  367. github: true,
  368. gitBridge: true,
  369. versioning: true,
  370. compileTimeout: 180,
  371. compileGroup: 'standard',
  372. references: true,
  373. templates: true,
  374. trackChanges: true,
  375. }),
  376. // featuresEpoch: 'YYYY-MM-DD',
  377. features: {
  378. personal: defaultFeatures,
  379. },
  380. groupPlanModalOptions: {
  381. plan_codes: [],
  382. currencies: [],
  383. sizes: [],
  384. usages: [],
  385. },
  386. plans: [
  387. {
  388. planCode: 'personal',
  389. name: 'Personal',
  390. price_in_cents: 0,
  391. features: defaultFeatures,
  392. },
  393. ],
  394. enableSubscriptions: false,
  395. restrictedCountries: [],
  396. enableOnboardingEmails: process.env.ENABLE_ONBOARDING_EMAILS === 'true',
  397. enabledLinkedFileTypes: (process.env.ENABLED_LINKED_FILE_TYPES || '').split(
  398. ','
  399. ),
  400. // i18n
  401. // ------
  402. //
  403. i18n: {
  404. checkForHTMLInVars: process.env.I18N_CHECK_FOR_HTML_IN_VARS === 'true',
  405. escapeHTMLInVars: process.env.I18N_ESCAPE_HTML_IN_VARS === 'true',
  406. subdomainLang: {
  407. www: { lngCode: 'en', url: siteUrl },
  408. },
  409. defaultLng: 'en',
  410. },
  411. // Spelling languages
  412. // ------------------
  413. //
  414. // You must have the corresponding aspell package installed to
  415. // be able to use a language.
  416. languages: [
  417. { code: 'en', name: 'English' },
  418. { code: 'en_US', name: 'English (American)' },
  419. { code: 'en_GB', name: 'English (British)' },
  420. { code: 'en_CA', name: 'English (Canadian)' },
  421. { code: 'af', name: 'Afrikaans' },
  422. { code: 'ar', name: 'Arabic' },
  423. { code: 'gl', name: 'Galician' },
  424. { code: 'eu', name: 'Basque' },
  425. { code: 'br', name: 'Breton' },
  426. { code: 'bg', name: 'Bulgarian' },
  427. { code: 'ca', name: 'Catalan' },
  428. { code: 'hr', name: 'Croatian' },
  429. { code: 'cs', name: 'Czech' },
  430. { code: 'da', name: 'Danish' },
  431. { code: 'nl', name: 'Dutch' },
  432. { code: 'eo', name: 'Esperanto' },
  433. { code: 'et', name: 'Estonian' },
  434. { code: 'fo', name: 'Faroese' },
  435. { code: 'fr', name: 'French' },
  436. { code: 'de', name: 'German' },
  437. { code: 'el', name: 'Greek' },
  438. { code: 'id', name: 'Indonesian' },
  439. { code: 'ga', name: 'Irish' },
  440. { code: 'it', name: 'Italian' },
  441. { code: 'kk', name: 'Kazakh' },
  442. { code: 'ku', name: 'Kurdish' },
  443. { code: 'lv', name: 'Latvian' },
  444. { code: 'lt', name: 'Lithuanian' },
  445. { code: 'nr', name: 'Ndebele' },
  446. { code: 'ns', name: 'Northern Sotho' },
  447. { code: 'no', name: 'Norwegian' },
  448. { code: 'fa', name: 'Persian' },
  449. { code: 'pl', name: 'Polish' },
  450. { code: 'pt_BR', name: 'Portuguese (Brazilian)' },
  451. { code: 'pt_PT', name: 'Portuguese (European)' },
  452. { code: 'pa', name: 'Punjabi' },
  453. { code: 'ro', name: 'Romanian' },
  454. { code: 'ru', name: 'Russian' },
  455. { code: 'sk', name: 'Slovak' },
  456. { code: 'sl', name: 'Slovenian' },
  457. { code: 'st', name: 'Southern Sotho' },
  458. { code: 'es', name: 'Spanish' },
  459. { code: 'sv', name: 'Swedish' },
  460. { code: 'tl', name: 'Tagalog' },
  461. { code: 'ts', name: 'Tsonga' },
  462. { code: 'tn', name: 'Tswana' },
  463. { code: 'hsb', name: 'Upper Sorbian' },
  464. { code: 'cy', name: 'Welsh' },
  465. { code: 'xh', name: 'Xhosa' },
  466. ],
  467. translatedLanguages: {
  468. cn: '简体中文',
  469. cs: 'Čeština',
  470. da: 'Dansk',
  471. de: 'Deutsch',
  472. en: 'English',
  473. es: 'Español',
  474. fi: 'Suomi',
  475. fr: 'Français',
  476. it: 'Italiano',
  477. ja: '日本語',
  478. ko: '한국어',
  479. nl: 'Nederlands',
  480. no: 'Norsk',
  481. pl: 'Polski',
  482. pt: 'Português',
  483. ro: 'Română',
  484. ru: 'Русский',
  485. sv: 'Svenska',
  486. tr: 'Türkçe',
  487. uk: 'Українська',
  488. 'zh-CN': '简体中文',
  489. },
  490. maxDictionarySize: 1024 * 1024, // 1 MB
  491. // Password Settings
  492. // -----------
  493. // These restrict the passwords users can use when registering
  494. // opts are from http://antelle.github.io/passfield
  495. passwordStrengthOptions: {
  496. length: {
  497. min: 8,
  498. // Bcrypt does not support longer passwords than that.
  499. max: 72,
  500. },
  501. },
  502. elevateAccountSecurityAfterFailedLogin:
  503. parseInt(process.env.ELEVATED_ACCOUNT_SECURITY_AFTER_FAILED_LOGIN_MS, 10) ||
  504. 24 * 60 * 60 * 1000,
  505. deviceHistory: {
  506. cookieName: process.env.DEVICE_HISTORY_COOKIE_NAME || 'deviceHistory',
  507. entryExpiry:
  508. parseInt(process.env.DEVICE_HISTORY_ENTRY_EXPIRY_MS, 10) ||
  509. 90 * 24 * 60 * 60 * 1000,
  510. maxEntries: parseInt(process.env.DEVICE_HISTORY_MAX_ENTRIES, 10) || 10,
  511. secret: process.env.DEVICE_HISTORY_SECRET,
  512. },
  513. // Email support
  514. // -------------
  515. //
  516. // Overleaf uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
  517. // To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
  518. // email:
  519. // fromAddress: ""
  520. // replyTo: ""
  521. // lifecycle: false
  522. // # Example transport and parameter settings for Amazon SES
  523. // transport: "SES"
  524. // parameters:
  525. // AWSAccessKeyID: ""
  526. // AWSSecretKey: ""
  527. // For legacy reasons, we need to populate this object.
  528. sentry: {},
  529. // Production Settings
  530. // -------------------
  531. debugPugTemplates: process.env.DEBUG_PUG_TEMPLATES === 'true',
  532. precompilePugTemplatesAtBootTime: process.env
  533. .PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME
  534. ? process.env.PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME === 'true'
  535. : process.env.NODE_ENV === 'production',
  536. // Should javascript assets be served minified or not.
  537. useMinifiedJs: process.env.MINIFIED_JS === 'true' || false,
  538. // Should static assets be sent with a header to tell the browser to cache
  539. // them.
  540. cacheStaticAssets: false,
  541. // If you are running Overleaf over https, set this to true to send the
  542. // cookie with a secure flag (recommended).
  543. secureCookie: false,
  544. // 'SameSite' cookie setting. Can be set to 'lax', 'none' or 'strict'
  545. // 'lax' is recommended, as 'strict' will prevent people linking to projects
  546. // https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
  547. sameSiteCookie: 'lax',
  548. // If you are running Overleaf behind a proxy (like Apache, Nginx, etc)
  549. // then set this to true to allow it to correctly detect the forwarded IP
  550. // address and http/https protocol information.
  551. behindProxy: false,
  552. // Delay before closing the http server upon receiving a SIGTERM process signal.
  553. gracefulShutdownDelayInMs:
  554. parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '5', 10) * seconds,
  555. // Expose the hostname in the `X-Served-By` response header
  556. exposeHostname: process.env.EXPOSE_HOSTNAME === 'true',
  557. // Cookie max age (in milliseconds). Set to false for a browser session.
  558. cookieSessionLength: 5 * 24 * 60 * 60 * 1000, // 5 days
  559. // When true, only allow invites to be sent to email addresses that
  560. // already have user accounts
  561. restrictInvitesToExistingAccounts: false,
  562. // Should we allow access to any page without logging in? This includes
  563. // public projects, /learn, /templates, about pages, etc.
  564. allowPublicAccess: process.env.OVERLEAF_ALLOW_PUBLIC_ACCESS === 'true',
  565. // editor should be open by default
  566. editorIsOpen: process.env.EDITOR_OPEN !== 'false',
  567. // site should be open by default
  568. siteIsOpen: process.env.SITE_OPEN !== 'false',
  569. // status file for closing/opening the site at run-time, polled every 5s
  570. siteMaintenanceFile: process.env.SITE_MAINTENANCE_FILE,
  571. // Use a single compile directory for all users in a project
  572. // (otherwise each user has their own directory)
  573. // disablePerUserCompiles: true
  574. // Domain the client (pdfjs) should download the compiled pdf from
  575. pdfDownloadDomain: process.env.COMPILES_USER_CONTENT_DOMAIN, // "http://clsi-lb:3014"
  576. // By default turn on feature flag, can be overridden per request.
  577. enablePdfCaching: process.env.ENABLE_PDF_CACHING === 'true',
  578. // Maximum size of text documents in the real-time editing system.
  579. max_doc_length: 2 * 1024 * 1024, // 2mb
  580. primary_email_check_expiration: 1000 * 60 * 60 * 24 * 90, // 90 days
  581. // Maximum JSON size in HTTP requests
  582. // We should be able to process twice the max doc length, to allow for
  583. // - the doc content
  584. // - text ranges spanning the whole doc
  585. //
  586. // There's also overhead required for the JSON encoding and the UTF-8 encoding,
  587. // theoretically up to 3 times the max doc length. On the other hand, we don't
  588. // want to block the event loop with JSON parsing, so we try to find a
  589. // practical compromise.
  590. max_json_request_size:
  591. parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB
  592. // Internal configs
  593. // ----------------
  594. path: {
  595. // If we ever need to write something to disk (e.g. incoming requests
  596. // that need processing but may be too big for memory, then write
  597. // them to disk here).
  598. dumpFolder: Path.resolve(__dirname, '../data/dumpFolder'),
  599. uploadFolder: Path.resolve(__dirname, '../data/uploads'),
  600. },
  601. // Automatic Snapshots
  602. // -------------------
  603. automaticSnapshots: {
  604. // How long should we wait after the user last edited to
  605. // take a snapshot?
  606. waitTimeAfterLastEdit: 5 * minutes,
  607. // Even if edits are still taking place, this is maximum
  608. // time to wait before taking another snapshot.
  609. maxTimeBetweenSnapshots: 30 * minutes,
  610. },
  611. // Smoke test
  612. // ----------
  613. // Provide log in credentials and a project to be able to run
  614. // some basic smoke tests to check the core functionality.
  615. //
  616. smokeTest: {
  617. user: process.env.SMOKE_TEST_USER,
  618. userId: process.env.SMOKE_TEST_USER_ID,
  619. password: process.env.SMOKE_TEST_PASSWORD,
  620. projectId: process.env.SMOKE_TEST_PROJECT_ID,
  621. rateLimitSubject: process.env.SMOKE_TEST_RATE_LIMIT_SUBJECT || '127.0.0.1',
  622. stepTimeout: parseInt(process.env.SMOKE_TEST_STEP_TIMEOUT || '10000', 10),
  623. },
  624. appName: process.env.APP_NAME || 'Overleaf (Community Edition)',
  625. adminEmail: process.env.ADMIN_EMAIL || 'placeholder@example.com',
  626. adminDomains: process.env.ADMIN_DOMAINS
  627. ? JSON.parse(process.env.ADMIN_DOMAINS)
  628. : undefined,
  629. nav: {
  630. title: process.env.APP_NAME || 'Overleaf Community Edition',
  631. hide_powered_by: process.env.NAV_HIDE_POWERED_BY === 'true',
  632. left_footer: [],
  633. right_footer: [
  634. {
  635. text: "<i class='fa fa-github-square'></i> Fork on GitHub!",
  636. url: 'https://github.com/overleaf/overleaf',
  637. },
  638. ],
  639. showSubscriptionLink: false,
  640. header_extras: [],
  641. },
  642. // Example:
  643. // header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
  644. recaptcha: {
  645. endpoint:
  646. process.env.RECAPTCHA_ENDPOINT ||
  647. 'https://www.google.com/recaptcha/api/siteverify',
  648. trustedUsers: (process.env.CAPTCHA_TRUSTED_USERS || '')
  649. .split(',')
  650. .map(x => x.trim())
  651. .filter(x => x !== ''),
  652. disabled: {
  653. invite: true,
  654. login: true,
  655. passwordReset: true,
  656. register: true,
  657. addEmail: true,
  658. },
  659. },
  660. customisation: {},
  661. redirects: {
  662. '/templates/index': '/templates/',
  663. },
  664. reloadModuleViewsOnEachRequest: process.env.NODE_ENV === 'development',
  665. rateLimit: {
  666. autoCompile: {
  667. everyone: process.env.RATE_LIMIT_AUTO_COMPILE_EVERYONE || 100,
  668. standard: process.env.RATE_LIMIT_AUTO_COMPILE_STANDARD || 25,
  669. },
  670. },
  671. analytics: {
  672. enabled: false,
  673. },
  674. compileBodySizeLimitMb: process.env.COMPILE_BODY_SIZE_LIMIT_MB || 7,
  675. textExtensions: defaultTextExtensions.concat(
  676. parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
  677. ),
  678. // case-insensitive file names that is editable (doc) in the editor
  679. editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
  680. fileIgnorePattern:
  681. process.env.FILE_IGNORE_PATTERN ||
  682. '**/{{__MACOSX,.git,.texpadtmp,.R}{,/**},.!(latexmkrc),*.{dvi,aux,log,toc,out,pdfsync,synctex,synctex(busy),fdb_latexmk,fls,nlo,ind,glo,gls,glg,bbl,blg,doc,docx,gz,swp}}',
  683. validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
  684. emailConfirmationDisabled:
  685. process.env.EMAIL_CONFIRMATION_DISABLED === 'true' || false,
  686. emailAddressLimit: intFromEnv('EMAIL_ADDRESS_LIMIT', 10),
  687. enabledServices: (process.env.ENABLED_SERVICES || 'web,api')
  688. .split(',')
  689. .map(s => s.trim()),
  690. // module options
  691. // ----------
  692. modules: {
  693. sanitize: {
  694. options: {
  695. allowedTags: [
  696. 'h1',
  697. 'h2',
  698. 'h3',
  699. 'h4',
  700. 'h5',
  701. 'h6',
  702. 'blockquote',
  703. 'p',
  704. 'a',
  705. 'ul',
  706. 'ol',
  707. 'nl',
  708. 'li',
  709. 'b',
  710. 'i',
  711. 'strong',
  712. 'em',
  713. 'strike',
  714. 'code',
  715. 'hr',
  716. 'br',
  717. 'div',
  718. 'table',
  719. 'thead',
  720. 'col',
  721. 'caption',
  722. 'tbody',
  723. 'tr',
  724. 'th',
  725. 'td',
  726. 'tfoot',
  727. 'pre',
  728. 'iframe',
  729. 'img',
  730. 'figure',
  731. 'figcaption',
  732. 'span',
  733. 'source',
  734. 'video',
  735. 'del',
  736. ],
  737. allowedAttributes: {
  738. a: [
  739. 'href',
  740. 'name',
  741. 'target',
  742. 'class',
  743. 'event-tracking',
  744. 'event-tracking-ga',
  745. 'event-tracking-label',
  746. 'event-tracking-trigger',
  747. ],
  748. div: ['class', 'id', 'style'],
  749. h1: ['class', 'id'],
  750. h2: ['class', 'id'],
  751. h3: ['class', 'id'],
  752. h4: ['class', 'id'],
  753. h5: ['class', 'id'],
  754. h6: ['class', 'id'],
  755. col: ['width'],
  756. figure: ['class', 'id', 'style'],
  757. figcaption: ['class', 'id', 'style'],
  758. i: ['aria-hidden', 'aria-label', 'class', 'id'],
  759. iframe: [
  760. 'allowfullscreen',
  761. 'frameborder',
  762. 'height',
  763. 'src',
  764. 'style',
  765. 'width',
  766. ],
  767. img: ['alt', 'class', 'src', 'style'],
  768. source: ['src', 'type'],
  769. span: ['class', 'id', 'style'],
  770. strong: ['style'],
  771. table: ['border', 'class', 'id', 'style'],
  772. td: ['colspan', 'rowspan', 'headers', 'style'],
  773. th: [
  774. 'abbr',
  775. 'headers',
  776. 'colspan',
  777. 'rowspan',
  778. 'scope',
  779. 'sorted',
  780. 'style',
  781. ],
  782. tr: ['class'],
  783. video: ['alt', 'class', 'controls', 'height', 'width'],
  784. },
  785. },
  786. },
  787. },
  788. overleafModuleImports: {
  789. // modules to import (an empty array for each set of modules)
  790. //
  791. // Restart webpack after making changes.
  792. //
  793. createFileModes: [],
  794. devToolbar: [],
  795. gitBridge: [],
  796. publishModal: [],
  797. tprFileViewInfo: [],
  798. tprFileViewRefreshError: [],
  799. tprFileViewRefreshButton: [],
  800. tprFileViewNotOriginalImporter: [],
  801. newFilePromotions: [],
  802. contactUsModal: [],
  803. editorToolbarButtons: [],
  804. sourceEditorExtensions: [],
  805. sourceEditorComponents: [],
  806. pdfLogEntryComponents: [],
  807. sourceEditorCompletionSources: [],
  808. sourceEditorSymbolPalette: [],
  809. sourceEditorToolbarComponents: [],
  810. editorPromotions: [],
  811. langFeedbackLinkingWidgets: [],
  812. integrationLinkingWidgets: [],
  813. referenceLinkingWidgets: [],
  814. importProjectFromGithubModalWrapper: [],
  815. importProjectFromGithubMenu: [],
  816. editorLeftMenuSync: [],
  817. editorLeftMenuManageTemplate: [],
  818. oauth2Server: [],
  819. managedGroupSubscriptionEnrollmentNotification: [],
  820. managedGroupEnrollmentInvite: [],
  821. ssoCertificateInfo: [],
  822. // See comment at the definition of these variables.
  823. entryPointsIde,
  824. entryPointsMain,
  825. },
  826. moduleImportSequence: [
  827. 'history-v1',
  828. 'launchpad',
  829. 'server-ce-scripts',
  830. 'user-activate',
  831. ],
  832. csp: {
  833. enabled: process.env.CSP_ENABLED === 'true',
  834. reportOnly: process.env.CSP_REPORT_ONLY === 'true',
  835. reportPercentage: parseFloat(process.env.CSP_REPORT_PERCENTAGE) || 0,
  836. reportUri: process.env.CSP_REPORT_URI,
  837. exclude: ['app/views/project/editor'],
  838. },
  839. unsupportedBrowsers: {
  840. ie: '<=11',
  841. safari: '<=13',
  842. },
  843. // ID of the IEEE brand in the rails app
  844. ieeeBrandId: intFromEnv('IEEE_BRAND_ID', 15),
  845. managedUsers: {
  846. enabled: false,
  847. },
  848. }
  849. module.exports.mergeWith = function (overrides) {
  850. return merge(overrides, module.exports)
  851. }