settings.coffee 19 KB

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