settings.defaults.js 25 KB

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