settings.defaults.js 26 KB

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