settings.defaults.js 27 KB

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