settings.coffee 20 KB

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