settings.defaults.js 26 KB

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