settings.defaults.js 23 KB

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