settings.coffee 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. Path = require('path')
  2. # These credentials are used for authenticating api requests
  3. # between services that may need to go over public channels
  4. httpAuthUser = "sharelatex"
  5. httpAuthPass = "CRYPTO_RANDOM" # Randomly generated for you
  6. httpAuthUsers = {}
  7. httpAuthUsers[httpAuthUser] = httpAuthPass
  8. parse = (option)->
  9. if option?
  10. try
  11. opt = JSON.parse(option)
  12. return opt
  13. catch err
  14. console.error "problem parsing #{option}, invalid JSON"
  15. return undefined
  16. DATA_DIR = '/var/lib/sharelatex/data'
  17. TMP_DIR = '/var/lib/sharelatex/tmp'
  18. settings =
  19. # Databases
  20. # ---------
  21. # ShareLaTeX's main persistant data store is MongoDB (http://www.mongodb.org/)
  22. # Documentation about the URL connection string format can be found at:
  23. #
  24. # http://docs.mongodb.org/manual/reference/connection-string/
  25. #
  26. # The following works out of the box with Mongo's default settings:
  27. mongo:
  28. url : process.env["SHARELATEX_MONGO_URL"] or 'mongodb://dockerhost/sharelatex'
  29. # Redis is used in ShareLaTeX for high volume queries, like real-time
  30. # editing, and session management.
  31. #
  32. # The following config will work with Redis's default settings:
  33. redis:
  34. web: redisConfig =
  35. host: process.env["SHARELATEX_REDIS_HOST"] or "dockerhost"
  36. port: process.env["SHARELATEX_REDIS_PORT"] or "6379"
  37. password: process.env["SHARELATEX_REDIS_PASS"] or ""
  38. fairy: redisConfig
  39. # The compile server (the clsi) uses a SQL database to cache files and
  40. # meta-data. sqllite is the default, and the load is low enough that this will
  41. # be fine in production (we use sqllite at sharelatex.com).
  42. #
  43. # If you want to configure a different database, see the Sequelize documentation
  44. # for available options:
  45. #
  46. # https://github.com/sequelize/sequelize/wiki/API-Reference-Sequelize#example-usage
  47. #
  48. mysql:
  49. clsi:
  50. database: "clsi"
  51. username: "clsi"
  52. password: ""
  53. dialect: "sqlite"
  54. storage: Path.join(DATA_DIR, "db.sqlite")
  55. # File storage
  56. # ------------
  57. # ShareLaTeX can store binary files like images either locally or in Amazon
  58. # S3. The default is locally:
  59. filestore:
  60. backend: "fs"
  61. stores:
  62. user_files: Path.join(DATA_DIR, "user_files")
  63. template_files: Path.join(DATA_DIR, "template_files")
  64. # To use Amazon S3 as a storage backend, comment out the above config, and
  65. # uncomment the following, filling in your key, secret, and bucket name:
  66. #
  67. # filestore:
  68. # backend: "s3"
  69. # stores:
  70. # user_files: "BUCKET_NAME"
  71. # s3:
  72. # key: "AWS_KEY"
  73. # secret: "AWS_SECRET"
  74. #
  75. # Local disk caching
  76. # ------------------
  77. path:
  78. # If we ever need to write something to disk (e.g. incoming requests
  79. # that need processing but may be too big for memory), then write
  80. # them to disk here:
  81. dumpFolder: Path.join(TMP_DIR, "dumpFolder")
  82. # Where to write uploads before they are processed
  83. uploadFolder: Path.join(TMP_DIR, "uploads")
  84. # Where to write the project to disk before running LaTeX on it
  85. compilesDir: Path.join(DATA_DIR, "compiles")
  86. # Where to cache downloaded URLs for the CLSI
  87. clsiCacheDir: Path.join(DATA_DIR, "cache")
  88. # Server Config
  89. # -------------
  90. # Where your instance of ShareLaTeX can be found publicly. This is used
  91. # when emails are sent out and in generated links:
  92. siteUrl: siteUrl = process.env["SHARELATEX_SITE_URL"] or 'http://localhost'
  93. # The name this is used to describe your ShareLaTeX Installation
  94. appName: process.env["SHARELATEX_APP_NAME"] or "ShareLaTeX (Community Edition)"
  95. nav:
  96. title: process.env["SHARELATEX_NAV_TITLE"] or process.env["SHARELATEX_APP_NAME"] or "ShareLaTeX Community Edition"
  97. # The email address which users will be directed to as the main point of
  98. # contact for this installation of ShareLaTeX.
  99. adminEmail: process.env["SHARELATEX_ADMIN_EMAIL"] or "placeholder@example.com"
  100. # If provided, a sessionSecret is used to sign cookies so that they cannot be
  101. # spoofed. This is recommended.
  102. security:
  103. sessionSecret: process.env["SHARELATEX_SESSION_SECRET"] or "CRYPTO_RANDOM" # This was randomly generated for you
  104. # These credentials are used for authenticating api requests
  105. # between services that may need to go over public channels
  106. httpAuthUsers: httpAuthUsers
  107. # Should javascript assets be served minified or not. Note that you will
  108. # need to run `grunt compile:minify` within the web-sharelatex directory
  109. # to generate these.
  110. useMinifiedJs: true
  111. # Should static assets be sent with a header to tell the browser to cache
  112. # them. This should be false in development where changes are being made,
  113. # but should be set to true in production.
  114. cacheStaticAssets: true
  115. # If you are running ShareLaTeX over https, set this to true to send the
  116. # cookie with a secure flag (recommended).
  117. secureCookie: process.env["SHARELATEX_SECURE_COOKIE"]?
  118. # If you are running ShareLaTeX behind a proxy (like Apache, Nginx, etc)
  119. # then set this to true to allow it to correctly detect the forwarded IP
  120. # address and http/https protocol information.
  121. behindProxy: process.env["SHARELATEX_BEHIND_PROXY"] or false
  122. # Spell Check Languages
  123. # ---------------------
  124. #
  125. # You must have the corresponding aspell dictionary installed to
  126. # be able to use a language. Run `grunt check:aspell` to check which
  127. # dictionaries you have installed. These should be set for the `code` for
  128. # each language.
  129. languages: [{
  130. "code":"en", "name":"English (American)"
  131. },{
  132. "code":"en_GB", "name":"English (British)"
  133. },{
  134. "code":"af", "name":"Africaans"
  135. },{
  136. "code":"am", "name":"Amharic"
  137. },{
  138. "code":"ar", "name":"Arabic"
  139. },{
  140. "code":"hy", "name":"Armenian"
  141. },{
  142. "code":"gl", "name":"Galician"
  143. },{
  144. "code":"eu", "name":"Basque"
  145. },{
  146. "code":"bn", "name":"Bengali"
  147. },{
  148. "code":"br", "name":"Breton"
  149. },{
  150. "code":"bg", "name":"Bulgarian"
  151. },{
  152. "code":"ca", "name":"Catalan"
  153. },{
  154. "code":"hr", "name":"Croatian"
  155. },{
  156. "code":"cs", "name":"Czech"
  157. },{
  158. "code":"da", "name":"Danish"
  159. },{
  160. "code":"nl", "name":"Dutch"
  161. },{
  162. "code":"eo", "name":"Esperanto"
  163. },{
  164. "code":"et", "name":"Estonian"
  165. },{
  166. "code":"fo", "name":"Faroese"
  167. },{
  168. "code":"fr", "name":"French"
  169. },{
  170. "code":"de", "name":"German"
  171. },{
  172. "code":"el", "name":"Greek"
  173. },{
  174. "code":"gu", "name":"Gujarati"
  175. },{
  176. "code":"he", "name":"Hebrew"
  177. },{
  178. "code":"hi", "name":"Hindi"
  179. },{
  180. "code":"hu", "name":"Hungarian"
  181. },{
  182. "code":"is", "name":"Icelandic"
  183. },{
  184. "code":"id", "name":"Indonesian"
  185. },{
  186. "code":"ga", "name":"Irish"
  187. },{
  188. "code":"it", "name":"Italian"
  189. },{
  190. "code":"kn", "name":"Kannada"
  191. },{
  192. "code":"kk", "name":"Kazakh"
  193. },{
  194. "code":"ku", "name":"Kurdish"
  195. },{
  196. "code":"lv", "name":"Latvian"
  197. },{
  198. "code":"lt", "name":"Lithuanian"
  199. },{
  200. "code":"ml", "name":"Malayalam"
  201. },{
  202. "code":"mr", "name":"Marathi"
  203. },{
  204. "code":"nr", "name":"Ndebele"
  205. },{
  206. "code":"ns", "name":"Northern Sotho"
  207. },{
  208. "code":"no", "name":"Norwegian"
  209. },{
  210. "code":"or", "name":"Oriya"
  211. },{
  212. "code":"fa", "name":"Persian"
  213. },{
  214. "code":"pl", "name":"Polish"
  215. },{
  216. "code":"pt_BR", "name":"Portuguese (Brazilian)"
  217. },{
  218. "code":"pt_PT", "name":"Portuguese (European)"
  219. },{
  220. "code":"pa", "name":"Punjabi"
  221. },{
  222. "code":"ro", "name":"Romanian"
  223. },{
  224. "code":"ru", "name":"Russian"
  225. },{
  226. "code":"sk", "name":"Slovak"
  227. },{
  228. "code":"sl", "name":"Slovenian"
  229. },{
  230. "code":"st", "name":"Southern Sotho"
  231. },{
  232. "code":"es", "name":"Spanish"
  233. },{
  234. "code":"ss", "name":"Swazi"
  235. },{
  236. "code":"sv", "name":"Swedish"
  237. },{
  238. "code":"tl", "name":"Tagalog"
  239. },{
  240. "code":"ta", "name":"Tamil"
  241. },{
  242. "code":"te", "name":"Telugu"
  243. },{
  244. "code":"ts", "name":"Tsonga"
  245. },{
  246. "code":"tn", "name":"Tswana"
  247. },{
  248. "code":"uk", "name":"Ukrainian"
  249. },{
  250. "code":"hsb", "name":"Upper Sorbian"
  251. },{
  252. "code":"uz", "name":"Uzbek"
  253. },{
  254. "code":"cy", "name":"Welsh"
  255. },{
  256. "code":"xh", "name":"Xhosa"
  257. },{
  258. "code":"zu", "name":"Zulu"
  259. }
  260. ]
  261. apis:
  262. web:
  263. url: "http://localhost:3000"
  264. user: httpAuthUser
  265. pass: httpAuthPass
  266. references:{}
  267. notifications:undefined
  268. #### OPTIONAL CONFIGERABLE SETTINGS
  269. if process.env["SHARELATEX_LEFT_FOOTER"]?
  270. try
  271. settings.nav.left_footer = JSON.parse(process.env["SHARELATEX_LEFT_FOOTER"])
  272. catch e
  273. console.error("could not parse SHARELATEX_LEFT_FOOTER, not valid JSON")
  274. if process.env["SHARELATEX_RIGHT_FOOTER"]?
  275. settings.nav.right_footer = process.env["SHARELATEX_RIGHT_FOOTER"]
  276. try
  277. settings.nav.right_footer = JSON.parse(process.env["SHARELATEX_RIGHT_FOOTER"])
  278. catch e
  279. console.error("could not parse SHARELATEX_RIGHT_FOOTER, not valid JSON")
  280. if process.env["SHARELATEX_HEADER_IMAGE_URL"]?
  281. settings.nav.custom_logo = process.env["SHARELATEX_HEADER_IMAGE_URL"]
  282. if process.env["SHARELATEX_HEADER"]?
  283. settings.nav.header = process.env["SHARELATEX_HEADER_NAV_LINKS"]
  284. # if process.env["SHARELATEX_PROXY_LEARN"]?
  285. # settings.nav.header.push({text: "help", class: "subdued", dropdown: [{text: "documentation", url: "/learn"}] })
  286. # Sending Email
  287. # -------------
  288. #
  289. # You must configure a mail server to be able to send invite emails from
  290. # ShareLaTeX. The config settings are passed to nodemailer. See the nodemailer
  291. # documentation for available options:
  292. #
  293. # http://www.nodemailer.com/docs/transports
  294. if process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]?
  295. settings.email =
  296. fromAddress: process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]
  297. replyTo: process.env["SHARELATEX_EMAIL_REPLY_TO"] or ""
  298. parameters:
  299. #AWS Creds
  300. AWSAccessKeyID: process.env["SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID"]
  301. AWSSecretKey: process.env["SHARELATEX_EMAIL_AWS_SES_SECRET_KEY"]
  302. #SMTP Creds
  303. host: process.env["SHARELATEX_EMAIL_SMTP_HOST"]
  304. port: process.env["SHARELATEX_EMAIL_SMTP_PORT"],
  305. secure: parse(process.env["SHARELATEX_EMAIL_SMTP_SECURE"])
  306. ignoreTLS: parse(process.env["SHARELATEX_EMAIL_SMTP_IGNORE_TLS"])
  307. templates:
  308. customFooter: process.env["SHARELATEX_CUSTOM_EMAIL_FOOTER"]
  309. if process.env["SHARELATEX_EMAIL_SMTP_USER"]? or process.env["SHARELATEX_EMAIL_SMTP_PASS"]?
  310. settings.email.parameters.auth =
  311. user: process.env["SHARELATEX_EMAIL_SMTP_USER"]
  312. pass: process.env["SHARELATEX_EMAIL_SMTP_PASS"]
  313. if process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"]?
  314. settings.email.parameters.tls =
  315. rejectUnauthorized: parse(process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"])
  316. # Password Settings
  317. # -----------
  318. # These restrict the passwords users can use when registering
  319. # opts are from http://antelle.github.io/passfield
  320. if process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"]
  321. settings.passwordStrengthOptions =
  322. pattern: process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or "aA$3"
  323. length: {min:process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or 8, max: process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"] or 50}
  324. #######################
  325. # ShareLaTeX Server Pro
  326. #######################
  327. if parse(process.env["SHARELATEX_IS_SERVER_PRO"]) == true
  328. settings.apis.references =
  329. url: "http://localhost:3040"
  330. # LDAP - SERVER PRO ONLY
  331. # ----------
  332. # Settings below use a working LDAP test server kindly provided by forumsys.com
  333. # When testing with forumsys.com use username = einstein and password = password
  334. if process.env["SHARELATEX_LDAP_HOST"]
  335. settings.ldap =
  336. host: process.env["SHARELATEX_LDAP_HOST"]
  337. dn: process.env["SHARELATEX_LDAP_DN"]
  338. baseSearch: process.env["SHARELATEX_LDAP_BASE_SEARCH"]
  339. filter: process.env["SHARELATEX_LDAP_FILTER"]
  340. failMessage: process.env["SHARELATEX_LDAP_FAIL_MESSAGE"] or 'LDAP User Fail'
  341. fieldName: process.env["SHARELATEX_LDAP_FIELD_NAME"] or 'LDAP User'
  342. placeholder: process.env["SHARELATEX_LDAP_PLACEHOLDER"] or 'LDAP User ID'
  343. emailAtt: process.env["SHARELATEX_LDAP_EMAIL_ATT"] or 'mail'
  344. anonymous: parse(process.env["SHARELATEX_LDAP_ANONYMOUS"])
  345. adminDN: process.env["SHARELATEX_LDAP_ADMIN_DN"]
  346. adminPW: process.env["SHARELATEX_LDAP_ADMIN_PW"]
  347. starttls: parse(process.env["SHARELATEX_LDAP_TLS"])
  348. nameAtt: process.env["SHARELATEX_LDAP_NAME_ATT"]
  349. lastNameAtt: process.env["SHARELATEX_LDAP_LAST_NAME_ATT"]
  350. if process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"]
  351. try
  352. ca = JSON.parse(process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"])
  353. catch e
  354. console.error "could not parse SHARELATEX_LDAP_TLS_OPTS_CA_PATH, invalid JSON"
  355. if typeof(ca) == 'string'
  356. ca_paths = [ca]
  357. else if typeof(ca) == 'object' && ca.length?
  358. ca_paths = ca
  359. else
  360. console.error "problem parsing SHARELATEX_LDAP_TLS_OPTS_CA_PATH"
  361. settings.ldap.tlsOptions =
  362. rejectUnauthorized: process.env["SHARELATEX_LDAP_TLS_OPTS_REJECT_UNAUTH"] == "true"
  363. ca:ca_paths # e.g.'/etc/ldap/ca_certs.pem'
  364. # Compiler
  365. # --------
  366. if process.env["SANDBOXED_COMPILES"] == "true"
  367. settings.clsi =
  368. commandRunner: "docker-runner-sharelatex"
  369. docker:
  370. image: process.env["TEX_LIVE_DOCKER_IMAGE"]
  371. env:
  372. 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"
  373. user: "www-data"
  374. if !settings.path?
  375. settings.path = {}
  376. settings.path.synctexBaseDir = () -> "/compile"
  377. # Templates
  378. # ---------
  379. if process.env["SHARELATEX_TEMPLATES_USER_ID"]
  380. settings.templates =
  381. mountPointUrl: "/templates"
  382. user_id: process.env["SHARELATEX_TEMPLATES_USER_ID"]
  383. settings.templateLinks = parse(process.env["SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS"])
  384. # /Learn
  385. # -------
  386. if process.env["SHARELATEX_PROXY_LEARN"]?
  387. settings.proxyLearn = parse(process.env["SHARELATEX_PROXY_LEARN"])
  388. # /References
  389. # -----------
  390. if process.env["SHARELATEX_ELASTICSEARCH_URL"]?
  391. settings.references.elasticsearch =
  392. host: process.env["SHARELATEX_ELASTICSEARCH_URL"]
  393. # With lots of incoming and outgoing HTTP connections to different services,
  394. # sometimes long running, it is a good idea to increase the default number
  395. # of sockets that Node will hold open.
  396. http = require('http')
  397. http.globalAgent.maxSockets = 300
  398. https = require('https')
  399. https.globalAgent.maxSockets = 300
  400. module.exports = settings