settings.coffee 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. Path = require('path')
  2. # These credentials are used for authenticating api requests
  3. # between services that may need to go over public channels
  4. httpAuthUser = "sharelatex"
  5. httpAuthPass = process.env["WEB_API_PASSWORD"]
  6. httpAuthUsers = {}
  7. httpAuthUsers[httpAuthUser] = httpAuthPass
  8. parse = (option)->
  9. if option?
  10. try
  11. opt = JSON.parse(option)
  12. return opt
  13. catch err
  14. console.error "problem parsing #{option}, invalid JSON"
  15. return undefined
  16. DATA_DIR = '/var/lib/sharelatex/data'
  17. TMP_DIR = '/var/lib/sharelatex/tmp'
  18. settings =
  19. brandPrefix: ""
  20. allowAnonymousReadAndWriteSharing:
  21. process.env['SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING'] == 'true'
  22. # Databases
  23. # ---------
  24. # ShareLaTeX's main persistant data store is MongoDB (http://www.mongodb.org/)
  25. # Documentation about the URL connection string format can be found at:
  26. #
  27. # http://docs.mongodb.org/manual/reference/connection-string/
  28. #
  29. # The following works out of the box with Mongo's default settings:
  30. mongo:
  31. url : process.env["SHARELATEX_MONGO_URL"] or 'mongodb://dockerhost/sharelatex'
  32. # Redis is used in ShareLaTeX for high volume queries, like real-time
  33. # editing, and session management.
  34. #
  35. # The following config will work with Redis's default settings:
  36. redis:
  37. web: redisConfig =
  38. host: process.env["SHARELATEX_REDIS_HOST"] or "dockerhost"
  39. port: process.env["SHARELATEX_REDIS_PORT"] or "6379"
  40. password: process.env["SHARELATEX_REDIS_PASS"] or ""
  41. key_schema:
  42. # document-updater
  43. blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
  44. docLines: ({doc_id}) -> "doclines:#{doc_id}"
  45. docOps: ({doc_id}) -> "DocOps:#{doc_id}"
  46. docVersion: ({doc_id}) -> "DocVersion:#{doc_id}"
  47. docHash: ({doc_id}) -> "DocHash:#{doc_id}"
  48. projectKey: ({doc_id}) -> "ProjectId:#{doc_id}"
  49. docsInProject: ({project_id}) -> "DocsIn:#{project_id}"
  50. ranges: ({doc_id}) -> "Ranges:#{doc_id}"
  51. # document-updater:realtime
  52. pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
  53. # document-updater:history
  54. uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
  55. docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
  56. # document-updater:lock
  57. blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
  58. # track-changes:lock
  59. historyLock: ({doc_id}) -> "HistoryLock:#{doc_id}"
  60. historyIndexLock: ({project_id}) -> "HistoryIndexLock:#{project_id}"
  61. # track-chanegs:history
  62. uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
  63. docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
  64. # realtime
  65. clientsInProject: ({project_id}) -> "clients_in_project:#{project_id}"
  66. connectedUser: ({project_id, client_id})-> "connected_user:#{project_id}:#{client_id}"
  67. fairy: redisConfig
  68. # track-changes and document-updater
  69. realtime: redisConfig
  70. documentupdater: redisConfig
  71. lock: redisConfig
  72. history: redisConfig
  73. websessions: redisConfig
  74. api: redisConfig
  75. pubsub: redisConfig
  76. project_history: redisConfig
  77. # The compile server (the clsi) uses a SQL database to cache files and
  78. # meta-data. sqllite is the default, and the load is low enough that this will
  79. # be fine in production (we use sqllite at sharelatex.com).
  80. #
  81. # If you want to configure a different database, see the Sequelize documentation
  82. # for available options:
  83. #
  84. # https://github.com/sequelize/sequelize/wiki/API-Reference-Sequelize#example-usage
  85. #
  86. mysql:
  87. clsi:
  88. database: "clsi"
  89. username: "clsi"
  90. password: ""
  91. dialect: "sqlite"
  92. storage: Path.join(DATA_DIR, "db.sqlite")
  93. # File storage
  94. # ------------
  95. # ShareLaTeX can store binary files like images either locally or in Amazon
  96. # S3. The default is locally:
  97. filestore:
  98. backend: "fs"
  99. stores:
  100. user_files: Path.join(DATA_DIR, "user_files")
  101. template_files: Path.join(DATA_DIR, "template_files")
  102. # To use Amazon S3 as a storage backend, comment out the above config, and
  103. # uncomment the following, filling in your key, secret, and bucket name:
  104. #
  105. # filestore:
  106. # backend: "s3"
  107. # stores:
  108. # user_files: "BUCKET_NAME"
  109. # s3:
  110. # key: "AWS_KEY"
  111. # secret: "AWS_SECRET"
  112. #
  113. trackchanges:
  114. continueOnError: true
  115. # Local disk caching
  116. # ------------------
  117. path:
  118. # If we ever need to write something to disk (e.g. incoming requests
  119. # that need processing but may be too big for memory), then write
  120. # them to disk here:
  121. dumpFolder: Path.join(TMP_DIR, "dumpFolder")
  122. # Where to write uploads before they are processed
  123. uploadFolder: Path.join(TMP_DIR, "uploads")
  124. # Where to write the project to disk before running LaTeX on it
  125. compilesDir: Path.join(DATA_DIR, "compiles")
  126. # Where to cache downloaded URLs for the CLSI
  127. clsiCacheDir: Path.join(DATA_DIR, "cache")
  128. # Server Config
  129. # -------------
  130. # Where your instance of ShareLaTeX can be found publicly. This is used
  131. # when emails are sent out and in generated links:
  132. siteUrl: siteUrl = process.env["SHARELATEX_SITE_URL"] or 'http://localhost'
  133. # The name this is used to describe your ShareLaTeX Installation
  134. appName: process.env["SHARELATEX_APP_NAME"] or "ShareLaTeX (Community Edition)"
  135. restrictInvitesToExistingAccounts: process.env["SHARELATEX_RESTRICT_INVITES_TO_EXISTING_ACCOUNTS"] == 'true'
  136. nav:
  137. title: process.env["SHARELATEX_NAV_TITLE"] or process.env["SHARELATEX_APP_NAME"] or "ShareLaTeX Community Edition"
  138. # The email address which users will be directed to as the main point of
  139. # contact for this installation of ShareLaTeX.
  140. adminEmail: process.env["SHARELATEX_ADMIN_EMAIL"] or "placeholder@example.com"
  141. # If provided, a sessionSecret is used to sign cookies so that they cannot be
  142. # spoofed. This is recommended.
  143. security:
  144. sessionSecret: process.env["SHARELATEX_SESSION_SECRET"] or process.env["CRYPTO_RANDOM"]
  145. # These credentials are used for authenticating api requests
  146. # between services that may need to go over public channels
  147. httpAuthUsers: httpAuthUsers
  148. # Should javascript assets be served minified or not.
  149. useMinifiedJs: true
  150. # Should static assets be sent with a header to tell the browser to cache
  151. # them. This should be false in development where changes are being made,
  152. # but should be set to true in production.
  153. cacheStaticAssets: true
  154. # If you are running ShareLaTeX over https, set this to true to send the
  155. # cookie with a secure flag (recommended).
  156. secureCookie: process.env["SHARELATEX_SECURE_COOKIE"]?
  157. # If you are running ShareLaTeX behind a proxy (like Apache, Nginx, etc)
  158. # then set this to true to allow it to correctly detect the forwarded IP
  159. # address and http/https protocol information.
  160. behindProxy: process.env["SHARELATEX_BEHIND_PROXY"] or false
  161. i18n:
  162. subdomainLang:
  163. www: {lngCode:process.env["SHARELATEX_SITE_LANGUAGE"] or "en", url: siteUrl}
  164. defaultLng: process.env["SHARELATEX_SITE_LANGUAGE"] or "en"
  165. apis:
  166. web:
  167. url: "http://localhost:3000"
  168. user: httpAuthUser
  169. pass: httpAuthPass
  170. project_history:
  171. enabled: false
  172. references:{}
  173. notifications:undefined
  174. defaultFeatures:
  175. collaborators: -1
  176. dropbox: true
  177. versioning: true
  178. compileTimeout: 180
  179. compileGroup: "standard"
  180. trackChanges: true
  181. templates: true
  182. references: true
  183. ## OPTIONAL CONFIGERABLE SETTINGS
  184. if process.env["SHARELATEX_LEFT_FOOTER"]?
  185. try
  186. settings.nav.left_footer = JSON.parse(process.env["SHARELATEX_LEFT_FOOTER"])
  187. catch e
  188. console.error("could not parse SHARELATEX_LEFT_FOOTER, not valid JSON")
  189. if process.env["SHARELATEX_RIGHT_FOOTER"]?
  190. settings.nav.right_footer = process.env["SHARELATEX_RIGHT_FOOTER"]
  191. try
  192. settings.nav.right_footer = JSON.parse(process.env["SHARELATEX_RIGHT_FOOTER"])
  193. catch e
  194. console.error("could not parse SHARELATEX_RIGHT_FOOTER, not valid JSON")
  195. if process.env["SHARELATEX_HEADER_IMAGE_URL"]?
  196. settings.nav.custom_logo = process.env["SHARELATEX_HEADER_IMAGE_URL"]
  197. if process.env["SHARELATEX_HEADER_NAV_LINKS"]?
  198. console.error """
  199. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  200. #
  201. # WARNING: SHARELATEX_HEADER_NAV_LINKS is no longer supported
  202. # See https://github.com/sharelatex/sharelatex/wiki/Configuring-Headers,-Footers-&-Logo
  203. #
  204. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  205. """
  206. if process.env["SHARELATEX_HEADER_EXTRAS"]?
  207. try
  208. settings.nav.header_extras = JSON.parse(process.env["SHARELATEX_HEADER_EXTRAS"])
  209. catch e
  210. console.error("could not parse SHARELATEX_HEADER_EXTRAS, not valid JSON")
  211. # Sending Email
  212. # -------------
  213. #
  214. # You must configure a mail server to be able to send invite emails from
  215. # ShareLaTeX. The config settings are passed to nodemailer. See the nodemailer
  216. # documentation for available options:
  217. #
  218. # http://www.nodemailer.com/docs/transports
  219. if process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]?
  220. settings.email =
  221. fromAddress: process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]
  222. replyTo: process.env["SHARELATEX_EMAIL_REPLY_TO"] or ""
  223. driver: process.env["SHARELATEX_EMAIL_DRIVER"]
  224. parameters:
  225. #AWS Creds
  226. AWSAccessKeyID: process.env["SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID"]
  227. AWSSecretKey: process.env["SHARELATEX_EMAIL_AWS_SES_SECRET_KEY"]
  228. #SMTP Creds
  229. host: process.env["SHARELATEX_EMAIL_SMTP_HOST"]
  230. port: process.env["SHARELATEX_EMAIL_SMTP_PORT"],
  231. secure: parse(process.env["SHARELATEX_EMAIL_SMTP_SECURE"])
  232. ignoreTLS: parse(process.env["SHARELATEX_EMAIL_SMTP_IGNORE_TLS"])
  233. textEncoding: process.env["SHARELATEX_EMAIL_TEXT_ENCODING"]
  234. templates:
  235. customFooter: process.env["SHARELATEX_CUSTOM_EMAIL_FOOTER"]
  236. if process.env["SHARELATEX_EMAIL_SMTP_USER"]? or process.env["SHARELATEX_EMAIL_SMTP_PASS"]?
  237. settings.email.parameters.auth =
  238. user: process.env["SHARELATEX_EMAIL_SMTP_USER"]
  239. pass: process.env["SHARELATEX_EMAIL_SMTP_PASS"]
  240. if process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"]?
  241. settings.email.parameters.tls =
  242. rejectUnauthorized: parse(process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"])
  243. # i18n
  244. if process.env["SHARELATEX_LANG_DOMAIN_MAPPING"]?
  245. settings.i18n.subdomainLang = parse(process.env["SHARELATEX_LANG_DOMAIN_MAPPING"])
  246. # Password Settings
  247. # -----------
  248. # These restrict the passwords users can use when registering
  249. # opts are from http://antelle.github.io/passfield
  250. if process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"]
  251. settings.passwordStrengthOptions =
  252. pattern: process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or "aA$3"
  253. length: {min:process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or 8, max: process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"] or 150}
  254. #######################
  255. # ShareLaTeX Server Pro
  256. #######################
  257. if parse(process.env["SHARELATEX_IS_SERVER_PRO"]) == true
  258. settings.bypassPercentageRollouts = true
  259. settings.apis.references =
  260. url: "http://localhost:3040"
  261. # LDAP - SERVER PRO ONLY
  262. # ----------
  263. if process.env["SHARELATEX_LDAP_HOST"]
  264. console.error """
  265. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  266. #
  267. # WARNING: The LDAP configuration format has changed in version 0.5.1
  268. # See https://github.com/sharelatex/sharelatex/wiki/Server-Pro:-LDAP-Config
  269. #
  270. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  271. """
  272. if process.env["SHARELATEX_LDAP_URL"]
  273. settings.externalAuth = true
  274. settings.ldap =
  275. emailAtt: process.env["SHARELATEX_LDAP_EMAIL_ATT"]
  276. nameAtt: process.env["SHARELATEX_LDAP_NAME_ATT"]
  277. lastNameAtt: process.env["SHARELATEX_LDAP_LAST_NAME_ATT"]
  278. updateUserDetailsOnLogin: process.env["SHARELATEX_LDAP_UPDATE_USER_DETAILS_ON_LOGIN"] == 'true'
  279. placeholder: process.env["SHARELATEX_LDAP_PLACEHOLDER"]
  280. server:
  281. url: process.env["SHARELATEX_LDAP_URL"]
  282. bindDn: process.env["SHARELATEX_LDAP_BIND_DN"]
  283. bindCredentials: process.env["SHARELATEX_LDAP_BIND_CREDENTIALS"]
  284. bindProperty: process.env["SHARELATEX_LDAP_BIND_PROPERTY"]
  285. searchBase: process.env["SHARELATEX_LDAP_SEARCH_BASE"]
  286. searchScope: process.env["SHARELATEX_LDAP_SEARCH_SCOPE"]
  287. searchFilter: process.env["SHARELATEX_LDAP_SEARCH_FILTER"]
  288. searchAttributes: (
  289. if _ldap_search_attribs = process.env["SHARELATEX_LDAP_SEARCH_ATTRIBUTES"]
  290. try
  291. JSON.parse(_ldap_search_attribs)
  292. catch e
  293. console.error "could not parse SHARELATEX_LDAP_SEARCH_ATTRIBUTES"
  294. else
  295. undefined
  296. )
  297. groupDnProperty: process.env["SHARELATEX_LDAP_GROUP_DN_PROPERTY"]
  298. groupSearchBase: process.env["SHARELATEX_LDAP_GROUP_SEARCH_BASE"]
  299. groupSearchScope: process.env["SHARELATEX_LDAP_GROUP_SEARCH_SCOPE"]
  300. groupSearchFilter: process.env["SHARELATEX_LDAP_GROUP_SEARCH_FILTER"]
  301. groupSearchAttributes: (
  302. if _ldap_group_search_attribs = process.env["SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES"]
  303. try
  304. JSON.parse(_ldap_group_search_attribs)
  305. catch e
  306. console.error "could not parse SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES"
  307. else
  308. undefined
  309. )
  310. cache: process.env["SHARELATEX_LDAP_CACHE"] == 'true'
  311. timeout: (
  312. if _ldap_timeout = process.env["SHARELATEX_LDAP_TIMEOUT"]
  313. try
  314. parseInt(_ldap_timeout)
  315. catch e
  316. console.error "Cannot parse SHARELATEX_LDAP_TIMEOUT"
  317. else
  318. undefined
  319. )
  320. connectTimeout: (
  321. if _ldap_connect_timeout = process.env["SHARELATEX_LDAP_CONNECT_TIMEOUT"]
  322. try
  323. parseInt(_ldap_connect_timeout)
  324. catch e
  325. console.error "Cannot parse SHARELATEX_LDAP_CONNECT_TIMEOUT"
  326. else
  327. undefined
  328. )
  329. if process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"]
  330. try
  331. ca = JSON.parse(process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"])
  332. catch e
  333. console.error "could not parse SHARELATEX_LDAP_TLS_OPTS_CA_PATH, invalid JSON"
  334. if typeof(ca) == 'string'
  335. ca_paths = [ca]
  336. else if typeof(ca) == 'object' && ca?.length?
  337. ca_paths = ca
  338. else
  339. console.error "problem parsing SHARELATEX_LDAP_TLS_OPTS_CA_PATH"
  340. settings.ldap.server.tlsOptions =
  341. rejectUnauthorized: process.env["SHARELATEX_LDAP_TLS_OPTS_REJECT_UNAUTH"] == "true"
  342. ca:ca_paths # e.g.'/etc/ldap/ca_certs.pem'
  343. if process.env["SHARELATEX_SAML_ENTRYPOINT"]
  344. # NOTE: see https://github.com/bergie/passport-saml/blob/master/README.md for docs of `server` options
  345. settings.externalAuth = true
  346. settings.saml =
  347. updateUserDetailsOnLogin: process.env["SHARELATEX_SAML_UPDATE_USER_DETAILS_ON_LOGIN"] == 'true'
  348. identityServiceName: process.env["SHARELATEX_SAML_IDENTITY_SERVICE_NAME"]
  349. emailField: process.env["SHARELATEX_SAML_EMAIL_FIELD"] || process.env["SHARELATEX_SAML_EMAIL_FIELD_NAME"]
  350. firstNameField: process.env["SHARELATEX_SAML_FIRST_NAME_FIELD"]
  351. lastNameField: process.env["SHARELATEX_SAML_LAST_NAME_FIELD"]
  352. server:
  353. # strings
  354. entryPoint: process.env["SHARELATEX_SAML_ENTRYPOINT"]
  355. callbackUrl: process.env["SHARELATEX_SAML_CALLBACK_URL"]
  356. issuer: process.env["SHARELATEX_SAML_ISSUER"]
  357. decryptionPvk: process.env["SHARELATEX_SAML_DECRYPTION_PVK"]
  358. signatureAlgorithm: process.env["SHARELATEX_SAML_SIGNATURE_ALGORITHM"]
  359. identifierFormat: process.env["SHARELATEX_SAML_IDENTIFIER_FORMAT"]
  360. attributeConsumingServiceIndex: process.env["SHARELATEX_SAML_ATTRIBUTE_CONSUMING_SERVICE_INDEX"]
  361. authnContext: process.env["SHARELATEX_SAML_AUTHN_CONTEXT"]
  362. authnRequestBinding: process.env["SHARELATEX_SAML_AUTHN_REQUEST_BINDING"]
  363. validateInResponseTo: process.env["SHARELATEX_SAML_VALIDATE_IN_RESPONSE_TO"]
  364. cacheProvider: process.env["SHARELATEX_SAML_CACHE_PROVIDER"]
  365. logoutUrl: process.env["SHARELATEX_SAML_LOGOUT_URL"]
  366. logoutCallbackUrl: process.env["SHARELATEX_SAML_LOGOUT_CALLBACK_URL"]
  367. disableRequestedAuthnContext: process.env["SHARELATEX_SAML_DISABLE_REQUESTED_AUTHN_CONTEXT"] == 'true'
  368. forceAuthn: process.env["SHARELATEX_SAML_FORCE_AUTHN"] == 'true'
  369. skipRequestCompression: process.env["SHARELATEX_SAML_SKIP_REQUEST_COMPRESSION"] == 'true'
  370. acceptedClockSkewMs: (
  371. if _saml_skew = process.env["SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS"]
  372. try
  373. parseInt(_saml_skew)
  374. catch e
  375. console.error "Cannot parse SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS"
  376. else
  377. undefined
  378. )
  379. requestIdExpirationPeriodMs: (
  380. if _saml_exiration = process.env["SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS"]
  381. try
  382. parseInt(_saml_expiration)
  383. catch e
  384. console.error "Cannot parse SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS"
  385. else
  386. undefined
  387. )
  388. additionalParams: (
  389. if _saml_additionalParams = process.env["SHARELATEX_SAML_ADDITIONAL_PARAMS"]
  390. try
  391. JSON.parse(_saml_additionalParams)
  392. catch e
  393. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_PARAMS"
  394. else
  395. undefined
  396. )
  397. additionalAuthorizeParams: (
  398. if _saml_additionalAuthorizeParams = process.env["SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"]
  399. try
  400. JSON.parse(_saml_additionalAuthorizeParams )
  401. catch e
  402. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"
  403. else
  404. undefined
  405. )
  406. additionalLogoutParams: (
  407. if _saml_additionalLogoutParams = process.env["SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"]
  408. try
  409. JSON.parse(_saml_additionalLogoutParams )
  410. catch e
  411. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"
  412. else
  413. undefined
  414. )
  415. # SHARELATEX_SAML_CERT cannot be empty
  416. # https://github.com/bergie/passport-saml/commit/f6b1c885c0717f1083c664345556b535f217c102
  417. if process.env["SHARELATEX_SAML_CERT"]
  418. settings.saml.server.cert = process.env["SHARELATEX_SAML_CERT"]
  419. settings.saml.server.privateCert = process.env["SHARELATEX_SAML_PRIVATE_CERT"]
  420. # Compiler
  421. # --------
  422. if process.env["SANDBOXED_COMPILES"] == "true"
  423. settings.clsi =
  424. dockerRunner: true
  425. docker:
  426. image: process.env["TEX_LIVE_DOCKER_IMAGE"]
  427. env:
  428. HOME: "/tmp"
  429. PATH: process.env["COMPILER_PATH"] or "/usr/local/texlive/2015/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  430. user: "www-data"
  431. if !settings.path?
  432. settings.path = {}
  433. settings.path.synctexBaseDir = () -> "/compile"
  434. if process.env['SANDBOXED_COMPILES_SIBLING_CONTAINERS'] == 'true'
  435. console.log("Using sibling containers for sandboxed compiles")
  436. if process.env['SANDBOXED_COMPILES_HOST_DIR']
  437. settings.path.sandboxedCompilesHostDir = process.env['SANDBOXED_COMPILES_HOST_DIR']
  438. else
  439. console.error('Sibling containers, but SANDBOXED_COMPILES_HOST_DIR not set')
  440. # Templates
  441. # ---------
  442. if process.env["SHARELATEX_TEMPLATES_USER_ID"]
  443. settings.templates =
  444. mountPointUrl: "/templates"
  445. user_id: process.env["SHARELATEX_TEMPLATES_USER_ID"]
  446. settings.templateLinks = parse(process.env["SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS"])
  447. # /Learn
  448. # -------
  449. if process.env["SHARELATEX_PROXY_LEARN"]?
  450. settings.proxyLearn = parse(process.env["SHARELATEX_PROXY_LEARN"])
  451. # /References
  452. # -----------
  453. if process.env["SHARELATEX_ELASTICSEARCH_URL"]?
  454. settings.references.elasticsearch =
  455. host: process.env["SHARELATEX_ELASTICSEARCH_URL"]
  456. # With lots of incoming and outgoing HTTP connections to different services,
  457. # sometimes long running, it is a good idea to increase the default number
  458. # of sockets that Node will hold open.
  459. http = require('http')
  460. http.globalAgent.maxSockets = 300
  461. https = require('https')
  462. https.globalAgent.maxSockets = 300
  463. module.exports = settings