settings.coffee 21 KB

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