settings.defaults.js 25 KB

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