settings.defaults.js 26 KB

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