settings.defaults.js 24 KB

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