settings.defaults.js 25 KB

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