settings.defaults.js 24 KB

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