settings.defaults.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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. projectUploadTimeout: parseInt(
  277. process.env.PROJECT_UPLOAD_TIMEOUT || '120000',
  278. 10
  279. ),
  280. maxUploadSize: 50 * 1024 * 1024, // 50 MB
  281. multerOptions: {
  282. preservePath: process.env.MULTER_PRESERVE_PATH,
  283. },
  284. // start failing the health check if active handles exceeds this limit
  285. maxActiveHandles: process.env.MAX_ACTIVE_HANDLES
  286. ? parseInt(process.env.MAX_ACTIVE_HANDLES, 10)
  287. : undefined,
  288. // Security
  289. // --------
  290. security: {
  291. sessionSecret,
  292. bcryptRounds: parseInt(process.env.BCRYPT_ROUNDS, 10) || 12,
  293. }, // number of rounds used to hash user passwords (raised to power 2)
  294. adminUrl: process.env.ADMIN_URL,
  295. adminOnlyLogin: process.env.ADMIN_ONLY_LOGIN === 'true',
  296. adminPrivilegeAvailable: process.env.ADMIN_PRIVILEGE_AVAILABLE === 'true',
  297. blockCrossOriginRequests: process.env.BLOCK_CROSS_ORIGIN_REQUESTS === 'true',
  298. allowedOrigins: (process.env.ALLOWED_ORIGINS || siteUrl).split(','),
  299. httpAuthUsers,
  300. // Default features
  301. // ----------------
  302. //
  303. // You can select the features that are enabled by default for new
  304. // new users.
  305. defaultFeatures: (defaultFeatures = {
  306. collaborators: -1,
  307. dropbox: true,
  308. github: true,
  309. gitBridge: true,
  310. versioning: true,
  311. compileTimeout: 180,
  312. compileGroup: 'standard',
  313. references: true,
  314. templates: true,
  315. trackChanges: true,
  316. }),
  317. // featuresEpoch: 'YYYY-MM-DD',
  318. features: {
  319. personal: defaultFeatures,
  320. },
  321. groupPlanModalOptions: {
  322. plan_codes: [],
  323. currencies: [],
  324. sizes: [],
  325. usages: [],
  326. },
  327. plans: [
  328. {
  329. planCode: 'personal',
  330. name: 'Personal',
  331. price_in_cents: 0,
  332. features: defaultFeatures,
  333. },
  334. ],
  335. enableSubscriptions: false,
  336. restrictedCountries: [],
  337. enabledLinkedFileTypes: (process.env.ENABLED_LINKED_FILE_TYPES || '').split(
  338. ','
  339. ),
  340. // i18n
  341. // ------
  342. //
  343. i18n: {
  344. checkForHTMLInVars: process.env.I18N_CHECK_FOR_HTML_IN_VARS === 'true',
  345. escapeHTMLInVars: process.env.I18N_ESCAPE_HTML_IN_VARS === 'true',
  346. subdomainLang: {
  347. www: { lngCode: 'en', url: siteUrl },
  348. },
  349. defaultLng: 'en',
  350. },
  351. // Spelling languages
  352. // ------------------
  353. //
  354. // You must have the corresponding aspell package installed to
  355. // be able to use a language.
  356. languages: [
  357. { code: 'en', name: 'English' },
  358. { code: 'en_US', name: 'English (American)' },
  359. { code: 'en_GB', name: 'English (British)' },
  360. { code: 'en_CA', name: 'English (Canadian)' },
  361. { code: 'af', name: 'Afrikaans' },
  362. { code: 'ar', name: 'Arabic' },
  363. { code: 'gl', name: 'Galician' },
  364. { code: 'eu', name: 'Basque' },
  365. { code: 'br', name: 'Breton' },
  366. { code: 'bg', name: 'Bulgarian' },
  367. { code: 'ca', name: 'Catalan' },
  368. { code: 'hr', name: 'Croatian' },
  369. { code: 'cs', name: 'Czech' },
  370. { code: 'da', name: 'Danish' },
  371. { code: 'nl', name: 'Dutch' },
  372. { code: 'eo', name: 'Esperanto' },
  373. { code: 'et', name: 'Estonian' },
  374. { code: 'fo', name: 'Faroese' },
  375. { code: 'fr', name: 'French' },
  376. { code: 'de', name: 'German' },
  377. { code: 'el', name: 'Greek' },
  378. { code: 'id', name: 'Indonesian' },
  379. { code: 'ga', name: 'Irish' },
  380. { code: 'it', name: 'Italian' },
  381. { code: 'kk', name: 'Kazakh' },
  382. { code: 'ku', name: 'Kurdish' },
  383. { code: 'lv', name: 'Latvian' },
  384. { code: 'lt', name: 'Lithuanian' },
  385. { code: 'nr', name: 'Ndebele' },
  386. { code: 'ns', name: 'Northern Sotho' },
  387. { code: 'no', name: 'Norwegian' },
  388. { code: 'fa', name: 'Persian' },
  389. { code: 'pl', name: 'Polish' },
  390. { code: 'pt_BR', name: 'Portuguese (Brazilian)' },
  391. { code: 'pt_PT', name: 'Portuguese (European)' },
  392. { code: 'pa', name: 'Punjabi' },
  393. { code: 'ro', name: 'Romanian' },
  394. { code: 'ru', name: 'Russian' },
  395. { code: 'sk', name: 'Slovak' },
  396. { code: 'sl', name: 'Slovenian' },
  397. { code: 'st', name: 'Southern Sotho' },
  398. { code: 'es', name: 'Spanish' },
  399. { code: 'sv', name: 'Swedish' },
  400. { code: 'tl', name: 'Tagalog' },
  401. { code: 'ts', name: 'Tsonga' },
  402. { code: 'tn', name: 'Tswana' },
  403. { code: 'hsb', name: 'Upper Sorbian' },
  404. { code: 'cy', name: 'Welsh' },
  405. { code: 'xh', name: 'Xhosa' },
  406. ],
  407. translatedLanguages: {
  408. cn: '简体中文',
  409. cs: 'Čeština',
  410. da: 'Dansk',
  411. de: 'Deutsch',
  412. en: 'English',
  413. es: 'Español',
  414. fi: 'Suomi',
  415. fr: 'Français',
  416. it: 'Italiano',
  417. ja: '日本語',
  418. ko: '한국어',
  419. nl: 'Nederlands',
  420. no: 'Norsk',
  421. pl: 'Polski',
  422. pt: 'Português',
  423. ro: 'Română',
  424. ru: 'Русский',
  425. sv: 'Svenska',
  426. tr: 'Türkçe',
  427. uk: 'Українська',
  428. 'zh-CN': '简体中文',
  429. },
  430. maxDictionarySize: 1024 * 1024, // 1 MB
  431. // Password Settings
  432. // -----------
  433. // These restrict the passwords users can use when registering
  434. // opts are from http://antelle.github.io/passfield
  435. passwordStrengthOptions: {
  436. length: {
  437. min: 8,
  438. // Bcrypt does not support longer passwords than that.
  439. max: 72,
  440. },
  441. },
  442. elevateAccountSecurityAfterFailedLogin:
  443. parseInt(process.env.ELEVATED_ACCOUNT_SECURITY_AFTER_FAILED_LOGIN_MS, 10) ||
  444. 24 * 60 * 60 * 1000,
  445. deviceHistory: {
  446. cookieName: process.env.DEVICE_HISTORY_COOKIE_NAME || 'deviceHistory',
  447. entryExpiry:
  448. parseInt(process.env.DEVICE_HISTORY_ENTRY_EXPIRY_MS, 10) ||
  449. 90 * 24 * 60 * 60 * 1000,
  450. maxEntries: parseInt(process.env.DEVICE_HISTORY_MAX_ENTRIES, 10) || 10,
  451. secret: process.env.DEVICE_HISTORY_SECRET,
  452. },
  453. // Email support
  454. // -------------
  455. //
  456. // ShareLaTeX uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
  457. // To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
  458. // email:
  459. // fromAddress: ""
  460. // replyTo: ""
  461. // lifecycle: false
  462. // # Example transport and parameter settings for Amazon SES
  463. // transport: "SES"
  464. // parameters:
  465. // AWSAccessKeyID: ""
  466. // AWSSecretKey: ""
  467. // For legacy reasons, we need to populate this object.
  468. sentry: {},
  469. // Production Settings
  470. // -------------------
  471. debugPugTemplates: process.env.DEBUG_PUG_TEMPLATES === 'true',
  472. precompilePugTemplatesAtBootTime: process.env
  473. .PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME
  474. ? process.env.PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME === 'true'
  475. : process.env.NODE_ENV === 'production',
  476. // Should javascript assets be served minified or not.
  477. useMinifiedJs: process.env.MINIFIED_JS === 'true' || false,
  478. // Should static assets be sent with a header to tell the browser to cache
  479. // them.
  480. cacheStaticAssets: false,
  481. // If you are running ShareLaTeX over https, set this to true to send the
  482. // cookie with a secure flag (recommended).
  483. secureCookie: false,
  484. // 'SameSite' cookie setting. Can be set to 'lax', 'none' or 'strict'
  485. // 'lax' is recommended, as 'strict' will prevent people linking to projects
  486. // https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
  487. sameSiteCookie: 'lax',
  488. // If you are running ShareLaTeX behind a proxy (like Apache, Nginx, etc)
  489. // then set this to true to allow it to correctly detect the forwarded IP
  490. // address and http/https protocol information.
  491. behindProxy: false,
  492. // Delay before closing the http server upon receiving a SIGTERM process signal.
  493. gracefulShutdownDelayInMs: parseInt(
  494. process.env.GRACEFUL_SHUTDOWN_DELAY || 30 * seconds,
  495. 10
  496. ),
  497. // Expose the hostname in the `X-Served-By` response header
  498. exposeHostname: process.env.EXPOSE_HOSTNAME === 'true',
  499. // Cookie max age (in milliseconds). Set to false for a browser session.
  500. cookieSessionLength: 5 * 24 * 60 * 60 * 1000, // 5 days
  501. // When true, only allow invites to be sent to email addresses that
  502. // already have user accounts
  503. restrictInvitesToExistingAccounts: false,
  504. // Should we allow access to any page without logging in? This includes
  505. // public projects, /learn, /templates, about pages, etc.
  506. allowPublicAccess: process.env.SHARELATEX_ALLOW_PUBLIC_ACCESS === 'true',
  507. // editor should be open by default
  508. editorIsOpen: process.env.EDITOR_OPEN !== 'false',
  509. // site should be open by default
  510. siteIsOpen: process.env.SITE_OPEN !== 'false',
  511. // status file for closing/opening the site at run-time, polled every 5s
  512. siteMaintenanceFile: process.env.SITE_MAINTENANCE_FILE,
  513. // Use a single compile directory for all users in a project
  514. // (otherwise each user has their own directory)
  515. // disablePerUserCompiles: true
  516. // Domain the client (pdfjs) should download the compiled pdf from
  517. pdfDownloadDomain: process.env.PDF_DOWNLOAD_DOMAIN, // "http://clsi-lb:3014"
  518. compilesUserContentDomain: process.env.COMPILES_USER_CONTENT_DOMAIN,
  519. // By default turn on feature flag, can be overridden per request.
  520. enablePdfCaching: process.env.ENABLE_PDF_CACHING === 'true',
  521. // Maximum size of text documents in the real-time editing system.
  522. max_doc_length: 2 * 1024 * 1024, // 2mb
  523. primary_email_check_expiration: 1000 * 60 * 60 * 24 * 90, // 90 days
  524. // Maximum JSON size in HTTP requests
  525. // We should be able to process twice the max doc length, to allow for
  526. // - the doc content
  527. // - text ranges spanning the whole doc
  528. //
  529. // There's also overhead required for the JSON encoding and the UTF-8 encoding,
  530. // theoretically up to 3 times the max doc length. On the other hand, we don't
  531. // want to block the event loop with JSON parsing, so we try to find a
  532. // practical compromise.
  533. max_json_request_size:
  534. parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB
  535. // Internal configs
  536. // ----------------
  537. path: {
  538. // If we ever need to write something to disk (e.g. incoming requests
  539. // that need processing but may be too big for memory, then write
  540. // them to disk here).
  541. dumpFolder: Path.resolve(__dirname, '../data/dumpFolder'),
  542. uploadFolder: Path.resolve(__dirname, '../data/uploads'),
  543. },
  544. // Automatic Snapshots
  545. // -------------------
  546. automaticSnapshots: {
  547. // How long should we wait after the user last edited to
  548. // take a snapshot?
  549. waitTimeAfterLastEdit: 5 * minutes,
  550. // Even if edits are still taking place, this is maximum
  551. // time to wait before taking another snapshot.
  552. maxTimeBetweenSnapshots: 30 * minutes,
  553. },
  554. // Smoke test
  555. // ----------
  556. // Provide log in credentials and a project to be able to run
  557. // some basic smoke tests to check the core functionality.
  558. //
  559. smokeTest: {
  560. user: process.env.SMOKE_TEST_USER,
  561. userId: process.env.SMOKE_TEST_USER_ID,
  562. password: process.env.SMOKE_TEST_PASSWORD,
  563. projectId: process.env.SMOKE_TEST_PROJECT_ID,
  564. rateLimitSubject: process.env.SMOKE_TEST_RATE_LIMIT_SUBJECT || '127.0.0.1',
  565. stepTimeout: parseInt(process.env.SMOKE_TEST_STEP_TIMEOUT || '10000', 10),
  566. },
  567. appName: process.env.APP_NAME || 'Overleaf (Community Edition)',
  568. adminEmail: process.env.ADMIN_EMAIL || 'placeholder@example.com',
  569. adminDomains: process.env.ADMIN_DOMAINS
  570. ? JSON.parse(process.env.ADMIN_DOMAINS)
  571. : undefined,
  572. nav: {
  573. title: process.env.APP_NAME || 'Overleaf Community Edition',
  574. hide_powered_by: process.env.NAV_HIDE_POWERED_BY === 'true',
  575. left_footer: [],
  576. right_footer: [
  577. {
  578. text: "<i class='fa fa-github-square'></i> Fork on GitHub!",
  579. url: 'https://github.com/overleaf/overleaf',
  580. },
  581. ],
  582. showSubscriptionLink: false,
  583. header_extras: [],
  584. },
  585. // Example:
  586. // header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
  587. recaptcha: {
  588. endpoint:
  589. process.env.RECAPTCHA_ENDPOINT ||
  590. 'https://www.google.com/recaptcha/api/siteverify',
  591. disabled: {
  592. invite: true,
  593. login: true,
  594. passwordReset: true,
  595. register: true,
  596. addEmail: true,
  597. },
  598. },
  599. customisation: {},
  600. redirects: {
  601. '/templates/index': '/templates/',
  602. },
  603. reloadModuleViewsOnEachRequest: process.env.NODE_ENV === 'development',
  604. rateLimit: {
  605. autoCompile: {
  606. everyone: process.env.RATE_LIMIT_AUTO_COMPILE_EVERYONE || 100,
  607. standard: process.env.RATE_LIMIT_AUTO_COMPILE_STANDARD || 25,
  608. },
  609. },
  610. analytics: {
  611. enabled: false,
  612. },
  613. compileBodySizeLimitMb: process.env.COMPILE_BODY_SIZE_LIMIT_MB || 7,
  614. textExtensions: defaultTextExtensions.concat(
  615. parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
  616. ),
  617. // case-insensitive file names that is editable (doc) in the editor
  618. editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
  619. fileIgnorePattern:
  620. process.env.FILE_IGNORE_PATTERN ||
  621. '**/{{__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}}',
  622. validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
  623. emailConfirmationDisabled:
  624. process.env.EMAIL_CONFIRMATION_DISABLED === 'true' || false,
  625. emailAddressLimit: intFromEnv('EMAIL_ADDRESS_LIMIT', 10),
  626. enabledServices: (process.env.ENABLED_SERVICES || 'web,api')
  627. .split(',')
  628. .map(s => s.trim()),
  629. // module options
  630. // ----------
  631. modules: {
  632. sanitize: {
  633. options: {
  634. allowedTags: [
  635. 'h1',
  636. 'h2',
  637. 'h3',
  638. 'h4',
  639. 'h5',
  640. 'h6',
  641. 'blockquote',
  642. 'p',
  643. 'a',
  644. 'ul',
  645. 'ol',
  646. 'nl',
  647. 'li',
  648. 'b',
  649. 'i',
  650. 'strong',
  651. 'em',
  652. 'strike',
  653. 'code',
  654. 'hr',
  655. 'br',
  656. 'div',
  657. 'table',
  658. 'thead',
  659. 'col',
  660. 'caption',
  661. 'tbody',
  662. 'tr',
  663. 'th',
  664. 'td',
  665. 'tfoot',
  666. 'pre',
  667. 'iframe',
  668. 'img',
  669. 'figure',
  670. 'figcaption',
  671. 'span',
  672. 'source',
  673. 'video',
  674. 'del',
  675. ],
  676. allowedAttributes: {
  677. a: [
  678. 'href',
  679. 'name',
  680. 'target',
  681. 'class',
  682. 'event-tracking',
  683. 'event-tracking-ga',
  684. 'event-tracking-label',
  685. 'event-tracking-trigger',
  686. ],
  687. div: ['class', 'id', 'style'],
  688. h1: ['class', 'id'],
  689. h2: ['class', 'id'],
  690. h3: ['class', 'id'],
  691. h4: ['class', 'id'],
  692. h5: ['class', 'id'],
  693. h6: ['class', 'id'],
  694. col: ['width'],
  695. figure: ['class', 'id', 'style'],
  696. figcaption: ['class', 'id', 'style'],
  697. i: ['aria-hidden', 'aria-label', 'class', 'id'],
  698. iframe: [
  699. 'allowfullscreen',
  700. 'frameborder',
  701. 'height',
  702. 'src',
  703. 'style',
  704. 'width',
  705. ],
  706. img: ['alt', 'class', 'src', 'style'],
  707. source: ['src', 'type'],
  708. span: ['class', 'id', 'style'],
  709. strong: ['style'],
  710. table: ['border', 'class', 'id', 'style'],
  711. td: ['colspan', 'rowspan', 'headers', 'style'],
  712. th: [
  713. 'abbr',
  714. 'headers',
  715. 'colspan',
  716. 'rowspan',
  717. 'scope',
  718. 'sorted',
  719. 'style',
  720. ],
  721. tr: ['class'],
  722. video: ['alt', 'class', 'controls', 'height', 'width'],
  723. },
  724. },
  725. },
  726. },
  727. overleafModuleImports: {
  728. // modules to import (an empty array for each set of modules)
  729. createFileModes: [],
  730. gitBridge: [],
  731. publishModal: [],
  732. tprLinkedFileInfo: [],
  733. tprLinkedFileRefreshError: [],
  734. contactUsModal: [],
  735. editorToolbarButtons: [],
  736. sourceEditorExtensions: [],
  737. sourceEditorComponents: [],
  738. sourceEditorCompletionSources: [],
  739. integrationLinkingWidgets: [],
  740. referenceLinkingWidgets: [],
  741. importProjectFromGithubModalWrapper: [],
  742. importProjectFromGithubMenu: [],
  743. editorLeftMenuSync: [],
  744. editorLeftMenuManageTemplate: [],
  745. oauth2Server: [],
  746. managedGroupSubscriptionEnrollmentNotification: [],
  747. managedGroupEnrollmentInvite: [],
  748. ssoConfigurationModal: [],
  749. entryPointsIde,
  750. entryPointsMain,
  751. },
  752. moduleImportSequence: [
  753. 'history-v1',
  754. 'launchpad',
  755. 'server-ce-scripts',
  756. 'user-activate',
  757. ],
  758. csp: {
  759. enabled: process.env.CSP_ENABLED === 'true',
  760. reportOnly: process.env.CSP_REPORT_ONLY === 'true',
  761. reportPercentage: parseFloat(process.env.CSP_REPORT_PERCENTAGE) || 0,
  762. reportUri: process.env.CSP_REPORT_URI,
  763. exclude: ['app/views/project/editor'],
  764. },
  765. unsupportedBrowsers: {
  766. ie: '<=11',
  767. },
  768. // ID of the IEEE brand in the rails app
  769. ieeeBrandId: intFromEnv('IEEE_BRAND_ID', 15),
  770. managedUsers: {
  771. enabled: false,
  772. },
  773. }
  774. module.exports.mergeWith = function (overrides) {
  775. return merge(overrides, module.exports)
  776. }