settings.defaults.js 25 KB

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