settings.coffee 21 KB

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