settings.defaults.js 24 KB

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