settings.defaults.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  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. defaultBackendClass: process.env.CLSI_DEFAULT_BACKEND_CLASS || 'e2',
  255. submissionBackendClass:
  256. process.env.CLSI_SUBMISSION_BACKEND_CLASS || 'n2d',
  257. },
  258. project_history: {
  259. sendProjectStructureOps: true,
  260. url: `http://${process.env.PROJECT_HISTORY_HOST || 'localhost'}:3054`,
  261. },
  262. realTime: {
  263. url: `http://${process.env.REALTIME_HOST || 'localhost'}:3026`,
  264. },
  265. contacts: {
  266. url: `http://${process.env.CONTACTS_HOST || 'localhost'}:3036`,
  267. },
  268. notifications: {
  269. url: `http://${process.env.NOTIFICATIONS_HOST || 'localhost'}:3042`,
  270. },
  271. webpack: {
  272. url: `http://${process.env.WEBPACK_HOST || 'localhost'}:3808`,
  273. },
  274. wiki: {
  275. url: process.env.WIKI_URL || 'https://learn.sharelatex.com',
  276. maxCacheAge: parseInt(process.env.WIKI_MAX_CACHE_AGE || 5 * minutes, 10),
  277. },
  278. haveIBeenPwned: {
  279. enabled: process.env.HAVE_I_BEEN_PWNED_ENABLED === 'true',
  280. url:
  281. process.env.HAVE_I_BEEN_PWNED_URL || 'https://api.pwnedpasswords.com',
  282. timeout: parseInt(process.env.HAVE_I_BEEN_PWNED_TIMEOUT, 10) || 5 * 1000,
  283. },
  284. // For legacy reasons, we need to populate the below objects.
  285. v1: {},
  286. recurly: {},
  287. },
  288. // Defines which features are allowed in the
  289. // Permissions-Policy HTTP header
  290. httpPermissions: httpPermissionsPolicy,
  291. useHttpPermissionsPolicy: true,
  292. jwt: {
  293. key: process.env.OT_JWT_AUTH_KEY,
  294. algorithm: process.env.OT_JWT_AUTH_ALG || 'HS256',
  295. },
  296. splitTest: {
  297. devToolbar: {
  298. enabled: false,
  299. },
  300. },
  301. splitTests: [],
  302. // Where your instance of Overleaf Community Edition/Server Pro can be found publicly. Used in emails
  303. // that are sent out, generated links, etc.
  304. siteUrl: (siteUrl = process.env.PUBLIC_URL || 'http://localhost:3000'),
  305. lockManager: {
  306. lockTestInterval: intFromEnv('LOCK_MANAGER_LOCK_TEST_INTERVAL', 50),
  307. maxTestInterval: intFromEnv('LOCK_MANAGER_MAX_TEST_INTERVAL', 1000),
  308. maxLockWaitTime: intFromEnv('LOCK_MANAGER_MAX_LOCK_WAIT_TIME', 10000),
  309. redisLockExpiry: intFromEnv('LOCK_MANAGER_REDIS_LOCK_EXPIRY', 30),
  310. slowExecutionThreshold: intFromEnv(
  311. 'LOCK_MANAGER_SLOW_EXECUTION_THRESHOLD',
  312. 5000
  313. ),
  314. },
  315. // Optional separate location for websocket connections, if unset defaults to siteUrl.
  316. wsUrl: process.env.WEBSOCKET_URL,
  317. wsUrlV2: process.env.WEBSOCKET_URL_V2,
  318. wsUrlBeta: process.env.WEBSOCKET_URL_BETA,
  319. wsUrlV2Percentage: parseInt(
  320. process.env.WEBSOCKET_URL_V2_PERCENTAGE || '0',
  321. 10
  322. ),
  323. wsRetryHandshake: parseInt(process.env.WEBSOCKET_RETRY_HANDSHAKE || '5', 10),
  324. // cookie domain
  325. // use full domain for cookies to only be accessible from that domain,
  326. // replace subdomain with dot to have them accessible on all subdomains
  327. cookieDomain: process.env.COOKIE_DOMAIN,
  328. cookieName: process.env.COOKIE_NAME || 'overleaf.sid',
  329. cookieRollingSession: true,
  330. // this is only used if cookies are used for clsi backend
  331. // clsiCookieKey: "clsiserver"
  332. robotsNoindex: process.env.ROBOTS_NOINDEX === 'true' || false,
  333. maxEntitiesPerProject: 2000,
  334. projectUploadTimeout: parseInt(
  335. process.env.PROJECT_UPLOAD_TIMEOUT || '120000',
  336. 10
  337. ),
  338. maxUploadSize: 50 * 1024 * 1024, // 50 MB
  339. multerOptions: {
  340. preservePath: process.env.MULTER_PRESERVE_PATH,
  341. },
  342. // start failing the health check if active handles exceeds this limit
  343. maxActiveHandles: process.env.MAX_ACTIVE_HANDLES
  344. ? parseInt(process.env.MAX_ACTIVE_HANDLES, 10)
  345. : undefined,
  346. // Security
  347. // --------
  348. security: {
  349. sessionSecret,
  350. bcryptRounds: parseInt(process.env.BCRYPT_ROUNDS, 10) || 12,
  351. }, // number of rounds used to hash user passwords (raised to power 2)
  352. adminUrl: process.env.ADMIN_URL,
  353. adminOnlyLogin: process.env.ADMIN_ONLY_LOGIN === 'true',
  354. adminPrivilegeAvailable: process.env.ADMIN_PRIVILEGE_AVAILABLE === 'true',
  355. blockCrossOriginRequests: process.env.BLOCK_CROSS_ORIGIN_REQUESTS === 'true',
  356. allowedOrigins: (process.env.ALLOWED_ORIGINS || siteUrl).split(','),
  357. httpAuthUsers,
  358. // Default features
  359. // ----------------
  360. //
  361. // You can select the features that are enabled by default for new
  362. // new users.
  363. defaultFeatures: (defaultFeatures = {
  364. collaborators: -1,
  365. dropbox: true,
  366. github: true,
  367. gitBridge: true,
  368. versioning: true,
  369. compileTimeout: 180,
  370. compileGroup: 'standard',
  371. references: true,
  372. templates: true,
  373. trackChanges: true,
  374. }),
  375. // featuresEpoch: 'YYYY-MM-DD',
  376. features: {
  377. personal: defaultFeatures,
  378. },
  379. groupPlanModalOptions: {
  380. plan_codes: [],
  381. currencies: [],
  382. sizes: [],
  383. usages: [],
  384. },
  385. plans: [
  386. {
  387. planCode: 'personal',
  388. name: 'Personal',
  389. price_in_cents: 0,
  390. features: defaultFeatures,
  391. },
  392. ],
  393. enableSubscriptions: false,
  394. restrictedCountries: [],
  395. enableOnboardingEmails: process.env.ENABLE_ONBOARDING_EMAILS === 'true',
  396. enabledLinkedFileTypes: (process.env.ENABLED_LINKED_FILE_TYPES || '').split(
  397. ','
  398. ),
  399. // i18n
  400. // ------
  401. //
  402. i18n: {
  403. checkForHTMLInVars: process.env.I18N_CHECK_FOR_HTML_IN_VARS === 'true',
  404. escapeHTMLInVars: process.env.I18N_ESCAPE_HTML_IN_VARS === 'true',
  405. subdomainLang: {
  406. www: { lngCode: 'en', url: siteUrl },
  407. },
  408. defaultLng: 'en',
  409. },
  410. // Spelling languages
  411. // ------------------
  412. //
  413. // You must have the corresponding aspell package installed to
  414. // be able to use a language.
  415. languages: [
  416. { code: 'en', name: 'English' },
  417. { code: 'en_US', name: 'English (American)' },
  418. { code: 'en_GB', name: 'English (British)' },
  419. { code: 'en_CA', name: 'English (Canadian)' },
  420. { code: 'af', name: 'Afrikaans' },
  421. { code: 'ar', name: 'Arabic' },
  422. { code: 'gl', name: 'Galician' },
  423. { code: 'eu', name: 'Basque' },
  424. { code: 'br', name: 'Breton' },
  425. { code: 'bg', name: 'Bulgarian' },
  426. { code: 'ca', name: 'Catalan' },
  427. { code: 'hr', name: 'Croatian' },
  428. { code: 'cs', name: 'Czech' },
  429. { code: 'da', name: 'Danish' },
  430. { code: 'nl', name: 'Dutch' },
  431. { code: 'eo', name: 'Esperanto' },
  432. { code: 'et', name: 'Estonian' },
  433. { code: 'fo', name: 'Faroese' },
  434. { code: 'fr', name: 'French' },
  435. { code: 'de', name: 'German' },
  436. { code: 'el', name: 'Greek' },
  437. { code: 'id', name: 'Indonesian' },
  438. { code: 'ga', name: 'Irish' },
  439. { code: 'it', name: 'Italian' },
  440. { code: 'kk', name: 'Kazakh' },
  441. { code: 'ku', name: 'Kurdish' },
  442. { code: 'lv', name: 'Latvian' },
  443. { code: 'lt', name: 'Lithuanian' },
  444. { code: 'nr', name: 'Ndebele' },
  445. { code: 'ns', name: 'Northern Sotho' },
  446. { code: 'no', name: 'Norwegian' },
  447. { code: 'fa', name: 'Persian' },
  448. { code: 'pl', name: 'Polish' },
  449. { code: 'pt_BR', name: 'Portuguese (Brazilian)' },
  450. { code: 'pt_PT', name: 'Portuguese (European)' },
  451. { code: 'pa', name: 'Punjabi' },
  452. { code: 'ro', name: 'Romanian' },
  453. { code: 'ru', name: 'Russian' },
  454. { code: 'sk', name: 'Slovak' },
  455. { code: 'sl', name: 'Slovenian' },
  456. { code: 'st', name: 'Southern Sotho' },
  457. { code: 'es', name: 'Spanish' },
  458. { code: 'sv', name: 'Swedish' },
  459. { code: 'tl', name: 'Tagalog' },
  460. { code: 'ts', name: 'Tsonga' },
  461. { code: 'tn', name: 'Tswana' },
  462. { code: 'hsb', name: 'Upper Sorbian' },
  463. { code: 'cy', name: 'Welsh' },
  464. { code: 'xh', name: 'Xhosa' },
  465. ],
  466. translatedLanguages: {
  467. cn: '简体中文',
  468. cs: 'Čeština',
  469. da: 'Dansk',
  470. de: 'Deutsch',
  471. en: 'English',
  472. es: 'Español',
  473. fi: 'Suomi',
  474. fr: 'Français',
  475. it: 'Italiano',
  476. ja: '日本語',
  477. ko: '한국어',
  478. nl: 'Nederlands',
  479. no: 'Norsk',
  480. pl: 'Polski',
  481. pt: 'Português',
  482. ro: 'Română',
  483. ru: 'Русский',
  484. sv: 'Svenska',
  485. tr: 'Türkçe',
  486. uk: 'Українська',
  487. 'zh-CN': '简体中文',
  488. },
  489. maxDictionarySize: 1024 * 1024, // 1 MB
  490. // Password Settings
  491. // -----------
  492. // These restrict the passwords users can use when registering
  493. // opts are from http://antelle.github.io/passfield
  494. passwordStrengthOptions: {
  495. length: {
  496. min: 8,
  497. // Bcrypt does not support longer passwords than that.
  498. max: 72,
  499. },
  500. },
  501. elevateAccountSecurityAfterFailedLogin:
  502. parseInt(process.env.ELEVATED_ACCOUNT_SECURITY_AFTER_FAILED_LOGIN_MS, 10) ||
  503. 24 * 60 * 60 * 1000,
  504. deviceHistory: {
  505. cookieName: process.env.DEVICE_HISTORY_COOKIE_NAME || 'deviceHistory',
  506. entryExpiry:
  507. parseInt(process.env.DEVICE_HISTORY_ENTRY_EXPIRY_MS, 10) ||
  508. 90 * 24 * 60 * 60 * 1000,
  509. maxEntries: parseInt(process.env.DEVICE_HISTORY_MAX_ENTRIES, 10) || 10,
  510. secret: process.env.DEVICE_HISTORY_SECRET,
  511. },
  512. // Email support
  513. // -------------
  514. //
  515. // Overleaf uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
  516. // To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
  517. // email:
  518. // fromAddress: ""
  519. // replyTo: ""
  520. // lifecycle: false
  521. // # Example transport and parameter settings for Amazon SES
  522. // transport: "SES"
  523. // parameters:
  524. // AWSAccessKeyID: ""
  525. // AWSSecretKey: ""
  526. // For legacy reasons, we need to populate this object.
  527. sentry: {},
  528. // Production Settings
  529. // -------------------
  530. debugPugTemplates: process.env.DEBUG_PUG_TEMPLATES === 'true',
  531. precompilePugTemplatesAtBootTime: process.env
  532. .PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME
  533. ? process.env.PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME === 'true'
  534. : process.env.NODE_ENV === 'production',
  535. // Should javascript assets be served minified or not.
  536. useMinifiedJs: process.env.MINIFIED_JS === 'true' || false,
  537. // Should static assets be sent with a header to tell the browser to cache
  538. // them.
  539. cacheStaticAssets: false,
  540. // If you are running Overleaf over https, set this to true to send the
  541. // cookie with a secure flag (recommended).
  542. secureCookie: false,
  543. // 'SameSite' cookie setting. Can be set to 'lax', 'none' or 'strict'
  544. // 'lax' is recommended, as 'strict' will prevent people linking to projects
  545. // https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
  546. sameSiteCookie: 'lax',
  547. // If you are running Overleaf behind a proxy (like Apache, Nginx, etc)
  548. // then set this to true to allow it to correctly detect the forwarded IP
  549. // address and http/https protocol information.
  550. behindProxy: false,
  551. // Delay before closing the http server upon receiving a SIGTERM process signal.
  552. gracefulShutdownDelayInMs:
  553. parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '5', 10) * seconds,
  554. // Expose the hostname in the `X-Served-By` response header
  555. exposeHostname: process.env.EXPOSE_HOSTNAME === 'true',
  556. // Cookie max age (in milliseconds). Set to false for a browser session.
  557. cookieSessionLength: 5 * 24 * 60 * 60 * 1000, // 5 days
  558. // When true, only allow invites to be sent to email addresses that
  559. // already have user accounts
  560. restrictInvitesToExistingAccounts: false,
  561. // Should we allow access to any page without logging in? This includes
  562. // public projects, /learn, /templates, about pages, etc.
  563. allowPublicAccess: process.env.OVERLEAF_ALLOW_PUBLIC_ACCESS === 'true',
  564. // editor should be open by default
  565. editorIsOpen: process.env.EDITOR_OPEN !== 'false',
  566. // site should be open by default
  567. siteIsOpen: process.env.SITE_OPEN !== 'false',
  568. // status file for closing/opening the site at run-time, polled every 5s
  569. siteMaintenanceFile: process.env.SITE_MAINTENANCE_FILE,
  570. // Use a single compile directory for all users in a project
  571. // (otherwise each user has their own directory)
  572. // disablePerUserCompiles: true
  573. // Domain the client (pdfjs) should download the compiled pdf from
  574. pdfDownloadDomain: process.env.COMPILES_USER_CONTENT_DOMAIN, // "http://clsi-lb:3014"
  575. // By default turn on feature flag, can be overridden per request.
  576. enablePdfCaching: process.env.ENABLE_PDF_CACHING === 'true',
  577. // Maximum size of text documents in the real-time editing system.
  578. max_doc_length: 2 * 1024 * 1024, // 2mb
  579. primary_email_check_expiration: 1000 * 60 * 60 * 24 * 90, // 90 days
  580. // Maximum JSON size in HTTP requests
  581. // We should be able to process twice the max doc length, to allow for
  582. // - the doc content
  583. // - text ranges spanning the whole doc
  584. //
  585. // There's also overhead required for the JSON encoding and the UTF-8 encoding,
  586. // theoretically up to 3 times the max doc length. On the other hand, we don't
  587. // want to block the event loop with JSON parsing, so we try to find a
  588. // practical compromise.
  589. max_json_request_size:
  590. parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB
  591. // Internal configs
  592. // ----------------
  593. path: {
  594. // If we ever need to write something to disk (e.g. incoming requests
  595. // that need processing but may be too big for memory, then write
  596. // them to disk here).
  597. dumpFolder: Path.resolve(__dirname, '../data/dumpFolder'),
  598. uploadFolder: Path.resolve(__dirname, '../data/uploads'),
  599. },
  600. // Automatic Snapshots
  601. // -------------------
  602. automaticSnapshots: {
  603. // How long should we wait after the user last edited to
  604. // take a snapshot?
  605. waitTimeAfterLastEdit: 5 * minutes,
  606. // Even if edits are still taking place, this is maximum
  607. // time to wait before taking another snapshot.
  608. maxTimeBetweenSnapshots: 30 * minutes,
  609. },
  610. // Smoke test
  611. // ----------
  612. // Provide log in credentials and a project to be able to run
  613. // some basic smoke tests to check the core functionality.
  614. //
  615. smokeTest: {
  616. user: process.env.SMOKE_TEST_USER,
  617. userId: process.env.SMOKE_TEST_USER_ID,
  618. password: process.env.SMOKE_TEST_PASSWORD,
  619. projectId: process.env.SMOKE_TEST_PROJECT_ID,
  620. rateLimitSubject: process.env.SMOKE_TEST_RATE_LIMIT_SUBJECT || '127.0.0.1',
  621. stepTimeout: parseInt(process.env.SMOKE_TEST_STEP_TIMEOUT || '10000', 10),
  622. },
  623. appName: process.env.APP_NAME || 'Overleaf (Community Edition)',
  624. adminEmail: process.env.ADMIN_EMAIL || 'placeholder@example.com',
  625. adminDomains: process.env.ADMIN_DOMAINS
  626. ? JSON.parse(process.env.ADMIN_DOMAINS)
  627. : undefined,
  628. nav: {
  629. title: process.env.APP_NAME || 'Overleaf Community Edition',
  630. hide_powered_by: process.env.NAV_HIDE_POWERED_BY === 'true',
  631. left_footer: [],
  632. right_footer: [
  633. {
  634. text: "<i class='fa fa-github-square'></i> Fork on GitHub!",
  635. url: 'https://github.com/overleaf/overleaf',
  636. },
  637. ],
  638. showSubscriptionLink: false,
  639. header_extras: [],
  640. },
  641. // Example:
  642. // header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
  643. recaptcha: {
  644. endpoint:
  645. process.env.RECAPTCHA_ENDPOINT ||
  646. 'https://www.google.com/recaptcha/api/siteverify',
  647. trustedUsers: (process.env.CAPTCHA_TRUSTED_USERS || '')
  648. .split(',')
  649. .map(x => x.trim())
  650. .filter(x => x !== ''),
  651. disabled: {
  652. invite: true,
  653. login: true,
  654. passwordReset: true,
  655. register: true,
  656. addEmail: true,
  657. },
  658. },
  659. customisation: {},
  660. redirects: {
  661. '/templates/index': '/templates/',
  662. },
  663. reloadModuleViewsOnEachRequest: process.env.NODE_ENV === 'development',
  664. rateLimit: {
  665. autoCompile: {
  666. everyone: process.env.RATE_LIMIT_AUTO_COMPILE_EVERYONE || 100,
  667. standard: process.env.RATE_LIMIT_AUTO_COMPILE_STANDARD || 25,
  668. },
  669. },
  670. analytics: {
  671. enabled: false,
  672. },
  673. compileBodySizeLimitMb: process.env.COMPILE_BODY_SIZE_LIMIT_MB || 7,
  674. textExtensions: defaultTextExtensions.concat(
  675. parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
  676. ),
  677. // case-insensitive file names that is editable (doc) in the editor
  678. editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
  679. fileIgnorePattern:
  680. process.env.FILE_IGNORE_PATTERN ||
  681. '**/{{__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}}',
  682. validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
  683. emailConfirmationDisabled:
  684. process.env.EMAIL_CONFIRMATION_DISABLED === 'true' || false,
  685. emailAddressLimit: intFromEnv('EMAIL_ADDRESS_LIMIT', 10),
  686. enabledServices: (process.env.ENABLED_SERVICES || 'web,api')
  687. .split(',')
  688. .map(s => s.trim()),
  689. // module options
  690. // ----------
  691. modules: {
  692. sanitize: {
  693. options: {
  694. allowedTags: [
  695. 'h1',
  696. 'h2',
  697. 'h3',
  698. 'h4',
  699. 'h5',
  700. 'h6',
  701. 'blockquote',
  702. 'p',
  703. 'a',
  704. 'ul',
  705. 'ol',
  706. 'nl',
  707. 'li',
  708. 'b',
  709. 'i',
  710. 'strong',
  711. 'em',
  712. 'strike',
  713. 'code',
  714. 'hr',
  715. 'br',
  716. 'div',
  717. 'table',
  718. 'thead',
  719. 'col',
  720. 'caption',
  721. 'tbody',
  722. 'tr',
  723. 'th',
  724. 'td',
  725. 'tfoot',
  726. 'pre',
  727. 'iframe',
  728. 'img',
  729. 'figure',
  730. 'figcaption',
  731. 'span',
  732. 'source',
  733. 'video',
  734. 'del',
  735. ],
  736. allowedAttributes: {
  737. a: [
  738. 'href',
  739. 'name',
  740. 'target',
  741. 'class',
  742. 'event-tracking',
  743. 'event-tracking-ga',
  744. 'event-tracking-label',
  745. 'event-tracking-trigger',
  746. ],
  747. div: ['class', 'id', 'style'],
  748. h1: ['class', 'id'],
  749. h2: ['class', 'id'],
  750. h3: ['class', 'id'],
  751. h4: ['class', 'id'],
  752. h5: ['class', 'id'],
  753. h6: ['class', 'id'],
  754. col: ['width'],
  755. figure: ['class', 'id', 'style'],
  756. figcaption: ['class', 'id', 'style'],
  757. i: ['aria-hidden', 'aria-label', 'class', 'id'],
  758. iframe: [
  759. 'allowfullscreen',
  760. 'frameborder',
  761. 'height',
  762. 'src',
  763. 'style',
  764. 'width',
  765. ],
  766. img: ['alt', 'class', 'src', 'style'],
  767. source: ['src', 'type'],
  768. span: ['class', 'id', 'style'],
  769. strong: ['style'],
  770. table: ['border', 'class', 'id', 'style'],
  771. td: ['colspan', 'rowspan', 'headers', 'style'],
  772. th: [
  773. 'abbr',
  774. 'headers',
  775. 'colspan',
  776. 'rowspan',
  777. 'scope',
  778. 'sorted',
  779. 'style',
  780. ],
  781. tr: ['class'],
  782. video: ['alt', 'class', 'controls', 'height', 'width'],
  783. },
  784. },
  785. },
  786. },
  787. overleafModuleImports: {
  788. // modules to import (an empty array for each set of modules)
  789. //
  790. // Restart webpack after making changes.
  791. //
  792. createFileModes: [],
  793. devToolbar: [],
  794. gitBridge: [],
  795. publishModal: [],
  796. tprFileViewInfo: [],
  797. tprFileViewRefreshError: [],
  798. tprFileViewRefreshButton: [],
  799. tprFileViewNotOriginalImporter: [],
  800. contactUsModal: [],
  801. editorToolbarButtons: [],
  802. sourceEditorExtensions: [],
  803. sourceEditorComponents: [],
  804. pdfLogsComponents: [],
  805. sourceEditorCompletionSources: [],
  806. sourceEditorSymbolPalette: [],
  807. sourceEditorToolbarComponents: [],
  808. writefullEditorPromotion: [],
  809. langFeedbackLinkingWidgets: [],
  810. integrationLinkingWidgets: [],
  811. referenceLinkingWidgets: [],
  812. importProjectFromGithubModalWrapper: [],
  813. importProjectFromGithubMenu: [],
  814. editorLeftMenuSync: [],
  815. editorLeftMenuManageTemplate: [],
  816. oauth2Server: [],
  817. managedGroupSubscriptionEnrollmentNotification: [],
  818. managedGroupEnrollmentInvite: [],
  819. ssoCertificateInfo: [],
  820. // See comment at the definition of these variables.
  821. entryPointsIde,
  822. entryPointsMain,
  823. },
  824. moduleImportSequence: [
  825. 'history-v1',
  826. 'launchpad',
  827. 'server-ce-scripts',
  828. 'user-activate',
  829. ],
  830. csp: {
  831. enabled: process.env.CSP_ENABLED === 'true',
  832. reportOnly: process.env.CSP_REPORT_ONLY === 'true',
  833. reportPercentage: parseFloat(process.env.CSP_REPORT_PERCENTAGE) || 0,
  834. reportUri: process.env.CSP_REPORT_URI,
  835. exclude: ['app/views/project/editor'],
  836. },
  837. unsupportedBrowsers: {
  838. ie: '<=11',
  839. safari: '<=13',
  840. },
  841. // ID of the IEEE brand in the rails app
  842. ieeeBrandId: intFromEnv('IEEE_BRAND_ID', 15),
  843. managedUsers: {
  844. enabled: false,
  845. },
  846. }
  847. module.exports.mergeWith = function (overrides) {
  848. return merge(overrides, module.exports)
  849. }