settings.defaults.js 23 KB

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