settings.coffee 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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. # Databases
  20. # ---------
  21. # ShareLaTeX's main persistant data store is MongoDB (http://www.mongodb.org/)
  22. # Documentation about the URL connection string format can be found at:
  23. #
  24. # http://docs.mongodb.org/manual/reference/connection-string/
  25. #
  26. # The following works out of the box with Mongo's default settings:
  27. mongo:
  28. url : process.env["SHARELATEX_MONGO_URL"] or 'mongodb://dockerhost/sharelatex'
  29. # Redis is used in ShareLaTeX for high volume queries, like real-time
  30. # editing, and session management.
  31. #
  32. # The following config will work with Redis's default settings:
  33. redis:
  34. web: redisConfig =
  35. host: process.env["SHARELATEX_REDIS_HOST"] or "dockerhost"
  36. port: process.env["SHARELATEX_REDIS_PORT"] or "6379"
  37. password: process.env["SHARELATEX_REDIS_PASS"] or ""
  38. fairy: redisConfig
  39. # The compile server (the clsi) uses a SQL database to cache files and
  40. # meta-data. sqllite is the default, and the load is low enough that this will
  41. # be fine in production (we use sqllite at sharelatex.com).
  42. #
  43. # If you want to configure a different database, see the Sequelize documentation
  44. # for available options:
  45. #
  46. # https://github.com/sequelize/sequelize/wiki/API-Reference-Sequelize#example-usage
  47. #
  48. mysql:
  49. clsi:
  50. database: "clsi"
  51. username: "clsi"
  52. password: ""
  53. dialect: "sqlite"
  54. storage: Path.join(DATA_DIR, "db.sqlite")
  55. # File storage
  56. # ------------
  57. # ShareLaTeX can store binary files like images either locally or in Amazon
  58. # S3. The default is locally:
  59. filestore:
  60. backend: "fs"
  61. stores:
  62. user_files: Path.join(DATA_DIR, "user_files")
  63. template_files: Path.join(DATA_DIR, "template_files")
  64. # To use Amazon S3 as a storage backend, comment out the above config, and
  65. # uncomment the following, filling in your key, secret, and bucket name:
  66. #
  67. # filestore:
  68. # backend: "s3"
  69. # stores:
  70. # user_files: "BUCKET_NAME"
  71. # s3:
  72. # key: "AWS_KEY"
  73. # secret: "AWS_SECRET"
  74. #
  75. # Local disk caching
  76. # ------------------
  77. path:
  78. # If we ever need to write something to disk (e.g. incoming requests
  79. # that need processing but may be too big for memory), then write
  80. # them to disk here:
  81. dumpFolder: Path.join(TMP_DIR, "dumpFolder")
  82. # Where to write uploads before they are processed
  83. uploadFolder: Path.join(TMP_DIR, "uploads")
  84. # Where to write the project to disk before running LaTeX on it
  85. compilesDir: Path.join(DATA_DIR, "compiles")
  86. # Where to cache downloaded URLs for the CLSI
  87. clsiCacheDir: Path.join(DATA_DIR, "cache")
  88. # Server Config
  89. # -------------
  90. # Where your instance of ShareLaTeX can be found publicly. This is used
  91. # when emails are sent out and in generated links:
  92. siteUrl: siteUrl = process.env["SHARELATEX_SITE_URL"] or 'http://localhost'
  93. # The name this is used to describe your ShareLaTeX Installation
  94. appName: process.env["SHARELATEX_APP_NAME"] or "ShareLaTeX (Community Edition)"
  95. restrictInvitesToExistingAccounts: process.env["SHARELATEX_RESTRICT_INVITES_TO_EXISTING_ACCOUNTS"] == 'true'
  96. nav:
  97. title: process.env["SHARELATEX_NAV_TITLE"] or process.env["SHARELATEX_APP_NAME"] or "ShareLaTeX Community Edition"
  98. # The email address which users will be directed to as the main point of
  99. # contact for this installation of ShareLaTeX.
  100. adminEmail: process.env["SHARELATEX_ADMIN_EMAIL"] or "placeholder@example.com"
  101. # If provided, a sessionSecret is used to sign cookies so that they cannot be
  102. # spoofed. This is recommended.
  103. security:
  104. sessionSecret: process.env["SHARELATEX_SESSION_SECRET"] or "CRYPTO_RANDOM" # This was randomly generated for you
  105. # These credentials are used for authenticating api requests
  106. # between services that may need to go over public channels
  107. httpAuthUsers: httpAuthUsers
  108. # Should javascript assets be served minified or not. Note that you will
  109. # need to run `grunt compile:minify` within the web-sharelatex directory
  110. # to generate these.
  111. useMinifiedJs: true
  112. # Should static assets be sent with a header to tell the browser to cache
  113. # them. This should be false in development where changes are being made,
  114. # but should be set to true in production.
  115. cacheStaticAssets: true
  116. # If you are running ShareLaTeX over https, set this to true to send the
  117. # cookie with a secure flag (recommended).
  118. secureCookie: process.env["SHARELATEX_SECURE_COOKIE"]?
  119. # If you are running ShareLaTeX behind a proxy (like Apache, Nginx, etc)
  120. # then set this to true to allow it to correctly detect the forwarded IP
  121. # address and http/https protocol information.
  122. behindProxy: process.env["SHARELATEX_BEHIND_PROXY"] or false
  123. # Spell Check Languages
  124. # ---------------------
  125. #
  126. # You must have the corresponding aspell dictionary installed to
  127. # be able to use a language. Run `grunt check:aspell` to check which
  128. # dictionaries you have installed. These should be set for the `code` for
  129. # each language.
  130. languages: [{
  131. "code":"en", "name":"English (American)"
  132. },{
  133. "code":"en_GB", "name":"English (British)"
  134. },{
  135. "code":"af", "name":"Africaans"
  136. },{
  137. "code":"am", "name":"Amharic"
  138. },{
  139. "code":"ar", "name":"Arabic"
  140. },{
  141. "code":"hy", "name":"Armenian"
  142. },{
  143. "code":"gl", "name":"Galician"
  144. },{
  145. "code":"eu", "name":"Basque"
  146. },{
  147. "code":"bn", "name":"Bengali"
  148. },{
  149. "code":"br", "name":"Breton"
  150. },{
  151. "code":"bg", "name":"Bulgarian"
  152. },{
  153. "code":"ca", "name":"Catalan"
  154. },{
  155. "code":"hr", "name":"Croatian"
  156. },{
  157. "code":"cs", "name":"Czech"
  158. },{
  159. "code":"da", "name":"Danish"
  160. },{
  161. "code":"nl", "name":"Dutch"
  162. },{
  163. "code":"eo", "name":"Esperanto"
  164. },{
  165. "code":"et", "name":"Estonian"
  166. },{
  167. "code":"fo", "name":"Faroese"
  168. },{
  169. "code":"fr", "name":"French"
  170. },{
  171. "code":"de", "name":"German"
  172. },{
  173. "code":"el", "name":"Greek"
  174. },{
  175. "code":"gu", "name":"Gujarati"
  176. },{
  177. "code":"he", "name":"Hebrew"
  178. },{
  179. "code":"hi", "name":"Hindi"
  180. },{
  181. "code":"hu", "name":"Hungarian"
  182. },{
  183. "code":"is", "name":"Icelandic"
  184. },{
  185. "code":"id", "name":"Indonesian"
  186. },{
  187. "code":"ga", "name":"Irish"
  188. },{
  189. "code":"it", "name":"Italian"
  190. },{
  191. "code":"kn", "name":"Kannada"
  192. },{
  193. "code":"kk", "name":"Kazakh"
  194. },{
  195. "code":"ku", "name":"Kurdish"
  196. },{
  197. "code":"lv", "name":"Latvian"
  198. },{
  199. "code":"lt", "name":"Lithuanian"
  200. },{
  201. "code":"ml", "name":"Malayalam"
  202. },{
  203. "code":"mr", "name":"Marathi"
  204. },{
  205. "code":"nr", "name":"Ndebele"
  206. },{
  207. "code":"ns", "name":"Northern Sotho"
  208. },{
  209. "code":"no", "name":"Norwegian"
  210. },{
  211. "code":"or", "name":"Oriya"
  212. },{
  213. "code":"fa", "name":"Persian"
  214. },{
  215. "code":"pl", "name":"Polish"
  216. },{
  217. "code":"pt_BR", "name":"Portuguese (Brazilian)"
  218. },{
  219. "code":"pt_PT", "name":"Portuguese (European)"
  220. },{
  221. "code":"pa", "name":"Punjabi"
  222. },{
  223. "code":"ro", "name":"Romanian"
  224. },{
  225. "code":"ru", "name":"Russian"
  226. },{
  227. "code":"sk", "name":"Slovak"
  228. },{
  229. "code":"sl", "name":"Slovenian"
  230. },{
  231. "code":"st", "name":"Southern Sotho"
  232. },{
  233. "code":"es", "name":"Spanish"
  234. },{
  235. "code":"ss", "name":"Swazi"
  236. },{
  237. "code":"sv", "name":"Swedish"
  238. },{
  239. "code":"tl", "name":"Tagalog"
  240. },{
  241. "code":"ta", "name":"Tamil"
  242. },{
  243. "code":"te", "name":"Telugu"
  244. },{
  245. "code":"ts", "name":"Tsonga"
  246. },{
  247. "code":"tn", "name":"Tswana"
  248. },{
  249. "code":"uk", "name":"Ukrainian"
  250. },{
  251. "code":"hsb", "name":"Upper Sorbian"
  252. },{
  253. "code":"uz", "name":"Uzbek"
  254. },{
  255. "code":"cy", "name":"Welsh"
  256. },{
  257. "code":"xh", "name":"Xhosa"
  258. },{
  259. "code":"zu", "name":"Zulu"
  260. }
  261. ]
  262. apis:
  263. web:
  264. url: "http://localhost:3000"
  265. user: httpAuthUser
  266. pass: httpAuthPass
  267. references:{}
  268. notifications:undefined
  269. defaultFeatures:
  270. collaborators: -1
  271. dropbox: true
  272. versioning: true
  273. compileTimeout: 180
  274. compileGroup: "standard"
  275. references: true
  276. templates: true
  277. ## OPTIONAL CONFIGERABLE SETTINGS
  278. if process.env["SHARELATEX_LEFT_FOOTER"]?
  279. try
  280. settings.nav.left_footer = JSON.parse(process.env["SHARELATEX_LEFT_FOOTER"])
  281. catch e
  282. console.error("could not parse SHARELATEX_LEFT_FOOTER, not valid JSON")
  283. if process.env["SHARELATEX_RIGHT_FOOTER"]?
  284. settings.nav.right_footer = process.env["SHARELATEX_RIGHT_FOOTER"]
  285. try
  286. settings.nav.right_footer = JSON.parse(process.env["SHARELATEX_RIGHT_FOOTER"])
  287. catch e
  288. console.error("could not parse SHARELATEX_RIGHT_FOOTER, not valid JSON")
  289. if process.env["SHARELATEX_HEADER_IMAGE_URL"]?
  290. settings.nav.custom_logo = process.env["SHARELATEX_HEADER_IMAGE_URL"]
  291. if process.env["SHARELATEX_HEADER_NAV_LINKS"]?
  292. try
  293. settings.nav.header = JSON.parse(process.env["SHARELATEX_HEADER_NAV_LINKS"])
  294. catch e
  295. console.error("could not parse SHARELATEX_HEADER_NAV_LINKS, not valid JSON")
  296. # if process.env["SHARELATEX_PROXY_LEARN"]?
  297. # settings.nav.header.push({text: "help", class: "subdued", dropdown: [{text: "documentation", url: "/learn"}] })
  298. # Sending Email
  299. # -------------
  300. #
  301. # You must configure a mail server to be able to send invite emails from
  302. # ShareLaTeX. The config settings are passed to nodemailer. See the nodemailer
  303. # documentation for available options:
  304. #
  305. # http://www.nodemailer.com/docs/transports
  306. if process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]?
  307. settings.email =
  308. fromAddress: process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]
  309. replyTo: process.env["SHARELATEX_EMAIL_REPLY_TO"] or ""
  310. parameters:
  311. #AWS Creds
  312. AWSAccessKeyID: process.env["SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID"]
  313. AWSSecretKey: process.env["SHARELATEX_EMAIL_AWS_SES_SECRET_KEY"]
  314. #SMTP Creds
  315. host: process.env["SHARELATEX_EMAIL_SMTP_HOST"]
  316. port: process.env["SHARELATEX_EMAIL_SMTP_PORT"],
  317. secure: parse(process.env["SHARELATEX_EMAIL_SMTP_SECURE"])
  318. ignoreTLS: parse(process.env["SHARELATEX_EMAIL_SMTP_IGNORE_TLS"])
  319. textEncoding: process.env["SHARELATEX_EMAIL_TEXT_ENCODING"]
  320. templates:
  321. customFooter: process.env["SHARELATEX_CUSTOM_EMAIL_FOOTER"]
  322. if process.env["SHARELATEX_EMAIL_SMTP_USER"]? or process.env["SHARELATEX_EMAIL_SMTP_PASS"]?
  323. settings.email.parameters.auth =
  324. user: process.env["SHARELATEX_EMAIL_SMTP_USER"]
  325. pass: process.env["SHARELATEX_EMAIL_SMTP_PASS"]
  326. if process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"]?
  327. settings.email.parameters.tls =
  328. rejectUnauthorized: parse(process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"])
  329. # Password Settings
  330. # -----------
  331. # These restrict the passwords users can use when registering
  332. # opts are from http://antelle.github.io/passfield
  333. if process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"]
  334. settings.passwordStrengthOptions =
  335. pattern: process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or "aA$3"
  336. length: {min:process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or 8, max: process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"] or 50}
  337. #######################
  338. # ShareLaTeX Server Pro
  339. #######################
  340. if parse(process.env["SHARELATEX_IS_SERVER_PRO"]) == true
  341. settings.apis.references =
  342. url: "http://localhost:3040"
  343. # LDAP - SERVER PRO ONLY
  344. # ----------
  345. if process.env["SHARELATEX_LDAP_HOST"]
  346. console.error """
  347. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  348. #
  349. # WARNING: The LDAP configuration format has changed in version 0.5.1
  350. # See https://github.com/sharelatex/sharelatex/wiki/Server-Pro:-LDAP-Config
  351. #
  352. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  353. """
  354. if process.env["SHARELATEX_LDAP_URL"]
  355. settings.externalAuth = true
  356. settings.ldap =
  357. emailAtt: process.env["SHARELATEX_LDAP_EMAIL_ATT"]
  358. nameAtt: process.env["SHARELATEX_LDAP_NAME_ATT"]
  359. lastNameAtt: process.env["SHARELATEX_LDAP_LAST_NAME_ATT"]
  360. updateUserDetailsOnLogin: process.env["SHARELATEX_LDAP_UPDATE_USER_DETAILS_ON_LOGIN"] == 'true'
  361. placeholder: process.env["SHARELATEX_LDAP_PLACEHOLDER"]
  362. server:
  363. url: process.env["SHARELATEX_LDAP_URL"]
  364. bindDn: process.env["SHARELATEX_LDAP_BIND_DN"]
  365. bindCredentials: process.env["SHARELATEX_LDAP_BIND_CREDENTIALS"]
  366. bindProperty: process.env["SHARELATEX_LDAP_BIND_PROPERTY"]
  367. searchBase: process.env["SHARELATEX_LDAP_SEARCH_BASE"]
  368. searchScope: process.env["SHARELATEX_LDAP_SEARCH_SCOPE"]
  369. searchFilter: process.env["SHARELATEX_LDAP_SEARCH_FILTER"]
  370. searchAttributes: (
  371. if _ldap_search_attribs = process.env["SHARELATEX_LDAP_SEARCH_ATTRIBUTES"]
  372. try
  373. JSON.parse(_ldap_search_attribs)
  374. catch e
  375. console.error "could not parse SHARELATEX_LDAP_SEARCH_ATTRIBUTES"
  376. else
  377. undefined
  378. )
  379. groupDnProperty: process.env["SHARELATEX_LDAP_GROUP_DN_PROPERTY"]
  380. groupSearchBase: process.env["SHARELATEX_LDAP_GROUP_SEARCH_BASE"]
  381. groupSearchScope: process.env["SHARELATEX_LDAP_GROUP_SEARCH_SCOPE"]
  382. groupSearchFilter: process.env["SHARELATEX_LDAP_GROUP_SEARCH_FILTER"]
  383. groupSearchAttributes: (
  384. if _ldap_group_search_attribs = process.env["SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES"]
  385. try
  386. JSON.parse(_ldap_group_search_attribs)
  387. catch e
  388. console.error "could not parse SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES"
  389. else
  390. undefined
  391. )
  392. cache: process.env["SHARELATEX_LDAP_CACHE"] == 'true'
  393. timeout: (
  394. if _ldap_timeout = process.env["SHARELATEX_LDAP_TIMEOUT"]
  395. try
  396. parseInt(_ldap_timeout)
  397. catch e
  398. console.error "Cannot parse SHARELATEX_LDAP_TIMEOUT"
  399. else
  400. undefined
  401. )
  402. connectTimeout: (
  403. if _ldap_connect_timeout = process.env["SHARELATEX_LDAP_CONNECT_TIMEOUT"]
  404. try
  405. parseInt(_ldap_connect_timeout)
  406. catch e
  407. console.error "Cannot parse SHARELATEX_LDAP_CONNECT_TIMEOUT"
  408. else
  409. undefined
  410. )
  411. if process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"]
  412. try
  413. ca = JSON.parse(process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"])
  414. catch e
  415. console.error "could not parse SHARELATEX_LDAP_TLS_OPTS_CA_PATH, invalid JSON"
  416. if typeof(ca) == 'string'
  417. ca_paths = [ca]
  418. else if typeof(ca) == 'object' && ca?.length?
  419. ca_paths = ca
  420. else
  421. console.error "problem parsing SHARELATEX_LDAP_TLS_OPTS_CA_PATH"
  422. settings.ldap.server.tlsOptions =
  423. rejectUnauthorized: process.env["SHARELATEX_LDAP_TLS_OPTS_REJECT_UNAUTH"] == "true"
  424. ca:ca_paths # e.g.'/etc/ldap/ca_certs.pem'
  425. if process.env["SHARELATEX_SAML_ENTRYPOINT"]
  426. # NOTE: see https://github.com/bergie/passport-saml/blob/master/README.md for docs of `server` options
  427. settings.externalAuth = true
  428. settings.saml =
  429. updateUserDetailsOnLogin: process.env["SHARELATEX_SAML_UPDATE_USER_DETAILS_ON_LOGIN"] == 'true'
  430. identityServiceName: process.env["SHARELATEX_SAML_IDENTITY_SERVICE_NAME"]
  431. emailField: process.env["SHARELATEX_SAML_EMAIL_FIELD"] || process.env["SHARELATEX_SAML_EMAIL_FIELD_NAME"]
  432. firstNameField: process.env["SHARELATEX_SAML_FIRST_NAME_FIELD"]
  433. lastNameField: process.env["SHARELATEX_SAML_LAST_NAME_FIELD"]
  434. server:
  435. # strings
  436. entryPoint: process.env["SHARELATEX_SAML_ENTRYPOINT"]
  437. callbackUrl: process.env["SHARELATEX_SAML_CALLBACK_URL"]
  438. issuer: process.env["SHARELATEX_SAML_ISSUER"]
  439. cert: process.env["SHARELATEX_SAML_CERT"]
  440. privateCert: process.env["SHARELATEX_SAML_PRIVATE_CERT"]
  441. decryptionPvk: process.env["SHARELATEX_SAML_DECRYPTION_PVK"]
  442. signatureAlgorithm: process.env["SHARELATEX_SAML_SIGNATURE_ALGORITHM"]
  443. identifierFormat: process.env["SHARELATEX_SAML_IDENTIFIER_FORMAT"]
  444. attributeConsumingServiceIndex: process.env["SHARELATEX_SAML_ATTRIBUTE_CONSUMING_SERVICE_INDEX"]
  445. authnContext: process.env["SHARELATEX_SAML_AUTHN_CONTEXT"]
  446. authnRequestBinding: process.env["SHARELATEX_SAML_AUTHN_REQUEST_BINDING"]
  447. validateInResponseTo: process.env["SHARELATEX_SAML_VALIDATE_IN_RESPONSE_TO"]
  448. cacheProvider: process.env["SHARELATEX_SAML_CACHE_PROVIDER"]
  449. logoutUrl: process.env["SHARELATEX_SAML_LOGOUT_URL"]
  450. logoutCallbackUrl: process.env["SHARELATEX_SAML_LOGOUT_CALLBACK_URL"]
  451. disableRequestedAuthnContext: process.env["SHARELATEX_SAML_DISABLE_REQUESTED_AUTHN_CONTEXT"] == 'true'
  452. forceAuthn: process.env["SHARELATEX_SAML_FORCE_AUTHN"] == 'true'
  453. skipRequestCompression: process.env["SHARELATEX_SAML_SKIP_REQUEST_COMPRESSION"] == 'true'
  454. acceptedClockSkewMs: (
  455. if _saml_skew = process.env["SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS"]
  456. try
  457. parseInt(_saml_skew)
  458. catch e
  459. console.error "Cannot parse SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS"
  460. else
  461. undefined
  462. )
  463. requestIdExpirationPeriodMs: (
  464. if _saml_exiration = process.env["SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS"]
  465. try
  466. parseInt(_saml_expiration)
  467. catch e
  468. console.error "Cannot parse SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS"
  469. else
  470. undefined
  471. )
  472. additionalParams: (
  473. if _saml_additionalParams = process.env["SHARELATEX_SAML_ADDITIONAL_PARAMS"]
  474. try
  475. JSON.parse(_saml_additionalParams)
  476. catch e
  477. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_PARAMS"
  478. else
  479. undefined
  480. )
  481. additionalAuthorizeParams: (
  482. if _saml_additionalAuthorizeParams = process.env["SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"]
  483. try
  484. JSON.parse(_saml_additionalAuthorizeParams )
  485. catch e
  486. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"
  487. else
  488. undefined
  489. )
  490. additionalLogoutParams: (
  491. if _saml_additionalLogoutParams = process.env["SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"]
  492. try
  493. JSON.parse(_saml_additionalLogoutParams )
  494. catch e
  495. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"
  496. else
  497. undefined
  498. )
  499. # Compiler
  500. # --------
  501. if process.env["SANDBOXED_COMPILES"] == "true"
  502. settings.clsi =
  503. commandRunner: "docker-runner-sharelatex"
  504. docker:
  505. image: process.env["TEX_LIVE_DOCKER_IMAGE"]
  506. env:
  507. HOME: "/tmp"
  508. 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"
  509. user: "www-data"
  510. if !settings.path?
  511. settings.path = {}
  512. settings.path.synctexBaseDir = () -> "/compile"
  513. # Templates
  514. # ---------
  515. if process.env["SHARELATEX_TEMPLATES_USER_ID"]
  516. settings.templates =
  517. mountPointUrl: "/templates"
  518. user_id: process.env["SHARELATEX_TEMPLATES_USER_ID"]
  519. settings.templateLinks = parse(process.env["SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS"])
  520. # /Learn
  521. # -------
  522. if process.env["SHARELATEX_PROXY_LEARN"]?
  523. settings.proxyLearn = parse(process.env["SHARELATEX_PROXY_LEARN"])
  524. # /References
  525. # -----------
  526. if process.env["SHARELATEX_ELASTICSEARCH_URL"]?
  527. settings.references.elasticsearch =
  528. host: process.env["SHARELATEX_ELASTICSEARCH_URL"]
  529. # With lots of incoming and outgoing HTTP connections to different services,
  530. # sometimes long running, it is a good idea to increase the default number
  531. # of sockets that Node will hold open.
  532. http = require('http')
  533. http.globalAgent.maxSockets = 300
  534. https = require('https')
  535. https.globalAgent.maxSockets = 300
  536. module.exports = settings