settings.coffee 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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. driver: process.env["SHARELATEX_EMAIL_DRIVER"]
  356. parameters:
  357. #AWS Creds
  358. AWSAccessKeyID: process.env["SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID"]
  359. AWSSecretKey: process.env["SHARELATEX_EMAIL_AWS_SES_SECRET_KEY"]
  360. #SMTP Creds
  361. host: process.env["SHARELATEX_EMAIL_SMTP_HOST"]
  362. port: process.env["SHARELATEX_EMAIL_SMTP_PORT"],
  363. secure: parse(process.env["SHARELATEX_EMAIL_SMTP_SECURE"])
  364. ignoreTLS: parse(process.env["SHARELATEX_EMAIL_SMTP_IGNORE_TLS"])
  365. textEncoding: process.env["SHARELATEX_EMAIL_TEXT_ENCODING"]
  366. templates:
  367. customFooter: process.env["SHARELATEX_CUSTOM_EMAIL_FOOTER"]
  368. if process.env["SHARELATEX_EMAIL_SMTP_USER"]? or process.env["SHARELATEX_EMAIL_SMTP_PASS"]?
  369. settings.email.parameters.auth =
  370. user: process.env["SHARELATEX_EMAIL_SMTP_USER"]
  371. pass: process.env["SHARELATEX_EMAIL_SMTP_PASS"]
  372. if process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"]?
  373. settings.email.parameters.tls =
  374. rejectUnauthorized: parse(process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"])
  375. # i18n
  376. if process.env["SHARELATEX_LANG_DOMAIN_MAPPING"]?
  377. settings.i18n.subdomainLang = parse(process.env["SHARELATEX_LANG_DOMAIN_MAPPING"])
  378. # Password Settings
  379. # -----------
  380. # These restrict the passwords users can use when registering
  381. # opts are from http://antelle.github.io/passfield
  382. if process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"]
  383. settings.passwordStrengthOptions =
  384. pattern: process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or "aA$3"
  385. length: {min:process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or 8, max: process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"] or 150}
  386. #######################
  387. # ShareLaTeX Server Pro
  388. #######################
  389. if parse(process.env["SHARELATEX_IS_SERVER_PRO"]) == true
  390. settings.apis.references =
  391. url: "http://localhost:3040"
  392. # LDAP - SERVER PRO ONLY
  393. # ----------
  394. if process.env["SHARELATEX_LDAP_HOST"]
  395. console.error """
  396. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  397. #
  398. # WARNING: The LDAP configuration format has changed in version 0.5.1
  399. # See https://github.com/sharelatex/sharelatex/wiki/Server-Pro:-LDAP-Config
  400. #
  401. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  402. """
  403. if process.env["SHARELATEX_LDAP_URL"]
  404. settings.externalAuth = true
  405. settings.ldap =
  406. emailAtt: process.env["SHARELATEX_LDAP_EMAIL_ATT"]
  407. nameAtt: process.env["SHARELATEX_LDAP_NAME_ATT"]
  408. lastNameAtt: process.env["SHARELATEX_LDAP_LAST_NAME_ATT"]
  409. updateUserDetailsOnLogin: process.env["SHARELATEX_LDAP_UPDATE_USER_DETAILS_ON_LOGIN"] == 'true'
  410. placeholder: process.env["SHARELATEX_LDAP_PLACEHOLDER"]
  411. server:
  412. url: process.env["SHARELATEX_LDAP_URL"]
  413. bindDn: process.env["SHARELATEX_LDAP_BIND_DN"]
  414. bindCredentials: process.env["SHARELATEX_LDAP_BIND_CREDENTIALS"]
  415. bindProperty: process.env["SHARELATEX_LDAP_BIND_PROPERTY"]
  416. searchBase: process.env["SHARELATEX_LDAP_SEARCH_BASE"]
  417. searchScope: process.env["SHARELATEX_LDAP_SEARCH_SCOPE"]
  418. searchFilter: process.env["SHARELATEX_LDAP_SEARCH_FILTER"]
  419. searchAttributes: (
  420. if _ldap_search_attribs = process.env["SHARELATEX_LDAP_SEARCH_ATTRIBUTES"]
  421. try
  422. JSON.parse(_ldap_search_attribs)
  423. catch e
  424. console.error "could not parse SHARELATEX_LDAP_SEARCH_ATTRIBUTES"
  425. else
  426. undefined
  427. )
  428. groupDnProperty: process.env["SHARELATEX_LDAP_GROUP_DN_PROPERTY"]
  429. groupSearchBase: process.env["SHARELATEX_LDAP_GROUP_SEARCH_BASE"]
  430. groupSearchScope: process.env["SHARELATEX_LDAP_GROUP_SEARCH_SCOPE"]
  431. groupSearchFilter: process.env["SHARELATEX_LDAP_GROUP_SEARCH_FILTER"]
  432. groupSearchAttributes: (
  433. if _ldap_group_search_attribs = process.env["SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES"]
  434. try
  435. JSON.parse(_ldap_group_search_attribs)
  436. catch e
  437. console.error "could not parse SHARELATEX_LDAP_GROUP_SEARCH_ATTRIBUTES"
  438. else
  439. undefined
  440. )
  441. cache: process.env["SHARELATEX_LDAP_CACHE"] == 'true'
  442. timeout: (
  443. if _ldap_timeout = process.env["SHARELATEX_LDAP_TIMEOUT"]
  444. try
  445. parseInt(_ldap_timeout)
  446. catch e
  447. console.error "Cannot parse SHARELATEX_LDAP_TIMEOUT"
  448. else
  449. undefined
  450. )
  451. connectTimeout: (
  452. if _ldap_connect_timeout = process.env["SHARELATEX_LDAP_CONNECT_TIMEOUT"]
  453. try
  454. parseInt(_ldap_connect_timeout)
  455. catch e
  456. console.error "Cannot parse SHARELATEX_LDAP_CONNECT_TIMEOUT"
  457. else
  458. undefined
  459. )
  460. if process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"]
  461. try
  462. ca = JSON.parse(process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"])
  463. catch e
  464. console.error "could not parse SHARELATEX_LDAP_TLS_OPTS_CA_PATH, invalid JSON"
  465. if typeof(ca) == 'string'
  466. ca_paths = [ca]
  467. else if typeof(ca) == 'object' && ca?.length?
  468. ca_paths = ca
  469. else
  470. console.error "problem parsing SHARELATEX_LDAP_TLS_OPTS_CA_PATH"
  471. settings.ldap.server.tlsOptions =
  472. rejectUnauthorized: process.env["SHARELATEX_LDAP_TLS_OPTS_REJECT_UNAUTH"] == "true"
  473. ca:ca_paths # e.g.'/etc/ldap/ca_certs.pem'
  474. if process.env["SHARELATEX_SAML_ENTRYPOINT"]
  475. # NOTE: see https://github.com/bergie/passport-saml/blob/master/README.md for docs of `server` options
  476. settings.externalAuth = true
  477. settings.saml =
  478. updateUserDetailsOnLogin: process.env["SHARELATEX_SAML_UPDATE_USER_DETAILS_ON_LOGIN"] == 'true'
  479. identityServiceName: process.env["SHARELATEX_SAML_IDENTITY_SERVICE_NAME"]
  480. emailField: process.env["SHARELATEX_SAML_EMAIL_FIELD"] || process.env["SHARELATEX_SAML_EMAIL_FIELD_NAME"]
  481. firstNameField: process.env["SHARELATEX_SAML_FIRST_NAME_FIELD"]
  482. lastNameField: process.env["SHARELATEX_SAML_LAST_NAME_FIELD"]
  483. server:
  484. # strings
  485. entryPoint: process.env["SHARELATEX_SAML_ENTRYPOINT"]
  486. callbackUrl: process.env["SHARELATEX_SAML_CALLBACK_URL"]
  487. issuer: process.env["SHARELATEX_SAML_ISSUER"]
  488. cert: process.env["SHARELATEX_SAML_CERT"]
  489. privateCert: process.env["SHARELATEX_SAML_PRIVATE_CERT"]
  490. decryptionPvk: process.env["SHARELATEX_SAML_DECRYPTION_PVK"]
  491. signatureAlgorithm: process.env["SHARELATEX_SAML_SIGNATURE_ALGORITHM"]
  492. identifierFormat: process.env["SHARELATEX_SAML_IDENTIFIER_FORMAT"]
  493. attributeConsumingServiceIndex: process.env["SHARELATEX_SAML_ATTRIBUTE_CONSUMING_SERVICE_INDEX"]
  494. authnContext: process.env["SHARELATEX_SAML_AUTHN_CONTEXT"]
  495. authnRequestBinding: process.env["SHARELATEX_SAML_AUTHN_REQUEST_BINDING"]
  496. validateInResponseTo: process.env["SHARELATEX_SAML_VALIDATE_IN_RESPONSE_TO"]
  497. cacheProvider: process.env["SHARELATEX_SAML_CACHE_PROVIDER"]
  498. logoutUrl: process.env["SHARELATEX_SAML_LOGOUT_URL"]
  499. logoutCallbackUrl: process.env["SHARELATEX_SAML_LOGOUT_CALLBACK_URL"]
  500. disableRequestedAuthnContext: process.env["SHARELATEX_SAML_DISABLE_REQUESTED_AUTHN_CONTEXT"] == 'true'
  501. forceAuthn: process.env["SHARELATEX_SAML_FORCE_AUTHN"] == 'true'
  502. skipRequestCompression: process.env["SHARELATEX_SAML_SKIP_REQUEST_COMPRESSION"] == 'true'
  503. acceptedClockSkewMs: (
  504. if _saml_skew = process.env["SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS"]
  505. try
  506. parseInt(_saml_skew)
  507. catch e
  508. console.error "Cannot parse SHARELATEX_SAML_ACCEPTED_CLOCK_SKEW_MS"
  509. else
  510. undefined
  511. )
  512. requestIdExpirationPeriodMs: (
  513. if _saml_exiration = process.env["SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS"]
  514. try
  515. parseInt(_saml_expiration)
  516. catch e
  517. console.error "Cannot parse SHARELATEX_SAML_REQUEST_ID_EXPIRATION_PERIOD_MS"
  518. else
  519. undefined
  520. )
  521. additionalParams: (
  522. if _saml_additionalParams = process.env["SHARELATEX_SAML_ADDITIONAL_PARAMS"]
  523. try
  524. JSON.parse(_saml_additionalParams)
  525. catch e
  526. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_PARAMS"
  527. else
  528. undefined
  529. )
  530. additionalAuthorizeParams: (
  531. if _saml_additionalAuthorizeParams = process.env["SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"]
  532. try
  533. JSON.parse(_saml_additionalAuthorizeParams )
  534. catch e
  535. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"
  536. else
  537. undefined
  538. )
  539. additionalLogoutParams: (
  540. if _saml_additionalLogoutParams = process.env["SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"]
  541. try
  542. JSON.parse(_saml_additionalLogoutParams )
  543. catch e
  544. console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"
  545. else
  546. undefined
  547. )
  548. # Compiler
  549. # --------
  550. if process.env["SANDBOXED_COMPILES"] == "true"
  551. settings.clsi =
  552. commandRunner: "docker-runner-sharelatex"
  553. docker:
  554. image: process.env["TEX_LIVE_DOCKER_IMAGE"]
  555. env:
  556. HOME: "/tmp"
  557. 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"
  558. user: "www-data"
  559. if !settings.path?
  560. settings.path = {}
  561. settings.path.synctexBaseDir = () -> "/compile"
  562. if process.env['SANDBOXED_COMPILES_SIBLING_CONTAINERS'] == 'true'
  563. console.log("Using sibling containers for sandoxed compiles")
  564. if process.env['SANDBOXED_COMPILES_HOST_DIR']
  565. settings.path.sandboxedCompilesHostDir = process.env['SANDBOXED_COMPILES_HOST_DIR']
  566. else
  567. console.error('Sibling containers, but SANDBOXED_COMPILES_HOST_DIR not set')
  568. # Templates
  569. # ---------
  570. if process.env["SHARELATEX_TEMPLATES_USER_ID"]
  571. settings.templates =
  572. mountPointUrl: "/templates"
  573. user_id: process.env["SHARELATEX_TEMPLATES_USER_ID"]
  574. settings.templateLinks = parse(process.env["SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS"])
  575. # /Learn
  576. # -------
  577. if process.env["SHARELATEX_PROXY_LEARN"]?
  578. settings.proxyLearn = parse(process.env["SHARELATEX_PROXY_LEARN"])
  579. # /References
  580. # -----------
  581. if process.env["SHARELATEX_ELASTICSEARCH_URL"]?
  582. settings.references.elasticsearch =
  583. host: process.env["SHARELATEX_ELASTICSEARCH_URL"]
  584. # With lots of incoming and outgoing HTTP connections to different services,
  585. # sometimes long running, it is a good idea to increase the default number
  586. # of sockets that Node will hold open.
  587. http = require('http')
  588. http.globalAgent.maxSockets = 300
  589. https = require('https')
  590. https.globalAgent.maxSockets = 300
  591. module.exports = settings