settings.coffee 20 KB

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