settings.coffee 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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",
  131. "name":"English (American)"
  132. },{
  133. "code":"en_GB",
  134. "name":"English (British)"
  135. },{
  136. "code":"af",
  137. "name":"Africaans"
  138. },{
  139. "code":"am",
  140. "name":"Amharic"
  141. },{
  142. "code":"ar",
  143. "name":"Arabic"
  144. },{
  145. "code":"hy",
  146. "name":"Armenian"
  147. },{
  148. "code":"gl",
  149. "name":"Galician"
  150. },{
  151. "code":"eu",
  152. "name":"Basque"
  153. },{
  154. "code":"bn",
  155. "name":"Bengali"
  156. },{
  157. "code":"br",
  158. "name":"Breton"
  159. },{
  160. "code":"bg",
  161. "name":"Bulgarian"
  162. },{
  163. "code":"ca",
  164. "name":"Catalan"
  165. },{
  166. "code":"hr",
  167. "name":"Croatian"
  168. },{
  169. "code":"cs",
  170. "name":"Czech"
  171. },{
  172. "code":"da",
  173. "name":"Danish"
  174. },{
  175. "code":"nl",
  176. "name":"Dutch"
  177. },{
  178. "code":"eo",
  179. "name":"Esperanto"
  180. },{
  181. "code":"et",
  182. "name":"Estonian"
  183. },{
  184. "code":"fo",
  185. "name":"Faroese"
  186. },{
  187. "code":"fr",
  188. "name":"French"
  189. },{
  190. "code":"de",
  191. "name":"German"
  192. },{
  193. "code":"el",
  194. "name":"Greek"
  195. },{
  196. "code":"gu",
  197. "name":"Gujarati"
  198. },{
  199. "code":"he",
  200. "name":"Hebrew"
  201. },{
  202. "code":"hi",
  203. "name":"Hindi"
  204. },{
  205. "code":"hu",
  206. "name":"Hungarian"
  207. },{
  208. "code":"is",
  209. "name":"Icelandic"
  210. },{
  211. "code":"id",
  212. "name":"Indonesian"
  213. },{
  214. "code":"ga",
  215. "name":"Irish"
  216. },{
  217. "code":"it",
  218. "name":"Italian"
  219. },{
  220. "code":"kn",
  221. "name":"Kannada"
  222. },{
  223. "code":"kk",
  224. "name":"Kazakh"
  225. },{
  226. "code":"ku",
  227. "name":"Kurdish"
  228. },{
  229. "code":"lv",
  230. "name":"Latvian"
  231. },{
  232. "code":"lt",
  233. "name":"Lithuanian"
  234. },{
  235. "code":"ml",
  236. "name":"Malayalam"
  237. },{
  238. "code":"mr",
  239. "name":"Marathi"
  240. },{
  241. "code":"nr",
  242. "name":"Ndebele"
  243. },{
  244. "code":"ns",
  245. "name":"Northern Sotho"
  246. },{
  247. "code":"no",
  248. "name":"Norwegian"
  249. },{
  250. "code":"or",
  251. "name":"Oriya"
  252. },{
  253. "code":"fa",
  254. "name":"Persian"
  255. },{
  256. "code":"pl",
  257. "name":"Polish"
  258. },{
  259. "code":"pt_BR",
  260. "name":"Portuguese (Brazilian)"
  261. },{
  262. "code":"pt_PT",
  263. "name":"Portuguese (European)"
  264. },{
  265. "code":"pa",
  266. "name":"Punjabi"
  267. },{
  268. "code":"ro",
  269. "name":"Romanian"
  270. },{
  271. "code":"ru",
  272. "name":"Russian"
  273. },{
  274. "code":"sk",
  275. "name":"Slovak"
  276. },{
  277. "code":"sl",
  278. "name":"Slovenian"
  279. },{
  280. "code":"st",
  281. "name":"Southern Sotho"
  282. },{
  283. "code":"es",
  284. "name":"Spanish"
  285. },{
  286. "code":"ss",
  287. "name":"Swazi"
  288. },{
  289. "code":"sv",
  290. "name":"Swedish"
  291. },{
  292. "code":"tl",
  293. "name":"Tagalog"
  294. },{
  295. "code":"ta",
  296. "name":"Tamil"
  297. },{
  298. "code":"te",
  299. "name":"Telugu"
  300. },{
  301. "code":"ts",
  302. "name":"Tsonga"
  303. },{
  304. "code":"tn",
  305. "name":"Tswana"
  306. },{
  307. "code":"uk",
  308. "name":"Ukrainian"
  309. },{
  310. "code":"hsb",
  311. "name":"Upper Sorbian"
  312. },{
  313. "code":"uz",
  314. "name":"Uzbek"
  315. },{
  316. "code":"cy",
  317. "name":"Welsh"
  318. },{
  319. "code":"xh",
  320. "name":"Xhosa"
  321. },{
  322. "code":"zu",
  323. "name":"Zulu"
  324. }
  325. ]
  326. # Service locations
  327. # -----------------
  328. # ShareLaTeX is comprised of many small services, which each expose
  329. # an HTTP API running on a different port. Generally you
  330. # can leave these as they are unless you have some other services
  331. # running which conflict, or want to run the web process on port 80.
  332. # internal:
  333. # web:
  334. # port: webPort = 3000
  335. # host: "localhost"
  336. # documentupdater:
  337. # port: docUpdaterPort = 3003
  338. # host: "localhost"
  339. # filestore:
  340. # port: filestorePort = 3009
  341. # host: "localhost"
  342. # chat:
  343. # port: chatPort = 3010
  344. # host: "localhost"
  345. # tags:
  346. # port: tagsPort = 3012
  347. # host: "localhost"
  348. # clsi:
  349. # port: clsiPort = 3013
  350. # host: "localhost"
  351. # trackchanges:
  352. # port: trackchangesPort = 3015
  353. # host: "localhost"
  354. # docstore:
  355. # port: docstorePort = 3016
  356. # host: "localhost"
  357. # spelling:
  358. # port: spellingPort = 3005
  359. # host: "localhost"
  360. # templates:
  361. # port: templatesPort = 3007
  362. # host: "localhost"
  363. # If you change the above config, or run some services on remote servers,
  364. # you need to tell the other services where to find them:
  365. apis:
  366. web:
  367. url: "http://localhost:3000"
  368. user: httpAuthUser
  369. pass: httpAuthPass
  370. references:undefined
  371. notifications:undefined
  372. # documentupdater:
  373. # url : "http://localhost:#{docUpdaterPort}"
  374. # clsi:
  375. # url: "http://localhost:#{clsiPort}"
  376. # filestore:
  377. # url: "http://localhost:#{filestorePort}"
  378. # trackchanges:
  379. # url: "http://localhost:#{trackchangesPort}"
  380. # docstore:
  381. # url: "http://localhost:#{docstorePort}"
  382. # tags:
  383. # url: "http://localhost:#{tagsPort}"
  384. # spelling:
  385. # url: "http://localhost:#{spellingPort}"
  386. # chat:
  387. # url: "http://localhost:#{chatPort}"
  388. # templates:
  389. # url: "http://localhost:#{templatesPort}"
  390. #### OPTIONAL CONFIGERABLE SETTINGS
  391. if process.env["SHARELATEX_LEFT_FOOTER"]?
  392. try
  393. settings.nav.left_footer = JSON.parse(process.env["SHARELATEX_LEFT_FOOTER"])
  394. catch e
  395. console.error("could not parse SHARELATEX_LEFT_FOOTER, not valid JSON")
  396. if process.env["SHARELATEX_RIGHT_FOOTER"]?
  397. settings.nav.right_footer = process.env["SHARELATEX_RIGHT_FOOTER"]
  398. try
  399. settings.nav.right_footer = JSON.parse(process.env["SHARELATEX_RIGHT_FOOTER"])
  400. catch e
  401. console.error("could not parse SHARELATEX_RIGHT_FOOTER, not valid JSON")
  402. if process.env["SHARELATEX_HEADER_IMAGE_URL"]?
  403. settings.nav.custom_logo = process.env["SHARELATEX_HEADER_IMAGE_URL"]
  404. if process.env["SHARELATEX_HEADER"]?
  405. settings.nav.header = process.env["SHARELATEX_HEADER"]
  406. # Sending Email
  407. # -------------
  408. #
  409. # You must configure a mail server to be able to send invite emails from
  410. # ShareLaTeX. The config settings are passed to nodemailer. See the nodemailer
  411. # documentation for available options:
  412. #
  413. # http://www.nodemailer.com/docs/transports
  414. if process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]?
  415. settings.email =
  416. fromAddress: process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]
  417. replyTo: process.env["SHARELATEX_EMAIL_REPLY_TO"] or ""
  418. parameters:
  419. #AWS Creds
  420. AWSAccessKeyID: process.env["SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID"]
  421. AWSSecretKey: process.env["SHARELATEX_EMAIL_AWS_SES_SECRET_KEY"]
  422. #SMTP Creds
  423. host: process.env["SHARELATEX_EMAIL_SMTP_HOST"]
  424. port: process.env["SHARELATEX_EMAIL_SMTP_PORT"],
  425. secure: parse(process.env["SHARELATEX_EMAIL_SMTP_SECURE"])
  426. ignoreTLS: parse(process.env["SHARELATEX_EMAIL_SMTP_IGNORE_TLS"])
  427. templates:
  428. customFooter: process.env["SHARELATEX_CUSTOM_EMAIL_FOOTER"]
  429. if process.env["SHARELATEX_EMAIL_SMTP_USER"]? or process.env["SHARELATEX_EMAIL_SMTP_PASS"]?
  430. settings.email.parameters.auth =
  431. user: process.env["SHARELATEX_EMAIL_SMTP_USER"]
  432. pass: process.env["SHARELATEX_EMAIL_SMTP_PASS"]
  433. if process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"]?
  434. settings.email.parameters.tls =
  435. rejectUnauthorized: parse(process.env["SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH"])
  436. # Password Settings
  437. # -----------
  438. # These restrict the passwords users can use when registering
  439. # opts are from http://antelle.github.io/passfield
  440. if process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"]
  441. settings.passwordStrengthOptions =
  442. pattern: process.env["SHARELATEX_PASSWORD_VALIDATION_PATTERN"] or "aA$3"
  443. length: {min:process.env["SHARELATEX_PASSWORD_VALIDATION_MIN_LENGTH"] or 8, max: process.env["SHARELATEX_PASSWORD_VALIDATION_MAX_LENGTH"] or 50}
  444. #######################
  445. # ShareLaTeX Server Pro
  446. #######################
  447. # LDAP - SERVER PRO ONLY
  448. # ----------
  449. # Settings below use a working LDAP test server kindly provided by forumsys.com
  450. # When testing with forumsys.com use username = einstein and password = password
  451. if process.env["SHARELATEX_LDAP_HOST"]
  452. settings.ldap =
  453. host: process.env["SHARELATEX_LDAP_HOST"]
  454. dn: process.env["SHARELATEX_LDAP_DN"]
  455. baseSearch: process.env["SHARELATEX_LDAP_BASE_SEARCH"]
  456. filter: process.env["SHARELATEX_LDAP_FILTER"]
  457. failMessage: process.env["SHARELATEX_LDAP_FAIL_MESSAGE"] or 'LDAP User Fail'
  458. fieldName: process.env["SHARELATEX_LDAP_FIELD_NAME"] or 'LDAP User'
  459. placeholder: process.env["SHARELATEX_LDAP_PLACEHOLDER"] or 'LDAP User ID'
  460. emailAtt: process.env["SHARELATEX_LDAP_EMAIL_ATT"] or 'mail'
  461. anonymous: parse(process.env["SHARELATEX_LDAP_ANONYMOUS"])
  462. adminDN: process.env["SHARELATEX_LDAP_ADMIN_DN"]
  463. adminPW: process.env["SHARELATEX_LDAP_ADMIN_PW"]
  464. starttls: parse(process.env["SHARELATEX_LDAP_TLS"])
  465. nameAtt: process.env["SHARELATEX_LDAP_NAME_ATT"]
  466. lastNameAtt: process.env["SHARELATEX_LDAP_LAST_NAME_ATT"]
  467. if process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"]
  468. try
  469. ca = JSON.parse(process.env["SHARELATEX_LDAP_TLS_OPTS_CA_PATH"])
  470. catch e
  471. console.error "could not parse SHARELATEX_LDAP_TLS_OPTS_CA_PATH, invalid JSON"
  472. if typeof(ca) == 'string'
  473. ca_paths = [ca]
  474. else if typeof(ca) == 'object' && ca.length?
  475. ca_paths = ca
  476. else
  477. console.error "problem parsing SHARELATEX_LDAP_TLS_OPTS_CA_PATH"
  478. settings.ldap.tlsOptions =
  479. rejectUnauthorized: process.env["SHARELATEX_LDAP_TLS_OPTS_REJECT_UNAUTH"] == "true"
  480. ca:ca_paths # e.g.'/etc/ldap/ca_certs.pem'
  481. # Compiler
  482. # --------
  483. if process.env["SANDBOXED_COMPILES"] == "true"
  484. settings.clsi =
  485. commandRunner: "docker-runner-sharelatex"
  486. docker:
  487. image: process.env["TEX_LIVE_DOCKER_IMAGE"]
  488. env:
  489. 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"
  490. user: "www-data"
  491. if !settings.path?
  492. settings.path = {}
  493. settings.path.synctexBaseDir = () -> "/compile"
  494. # Templates
  495. # ---------
  496. if process.env["SHARELATEX_TEMPLATES_USER_ID"]
  497. settings.templates =
  498. mountPointUrl: "/templates"
  499. user_id: process.env["SHARELATEX_TEMPLATES_USER_ID"]
  500. settings.templateLinks: parse(process.env["SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS"])
  501. # /Learn
  502. # -------
  503. if process.env["SHARELATEX_PROXY_LEARN"]?
  504. settings.proxyLearn = parse(process.env["SHARELATEX_PROXY_LEARN"])
  505. # With lots of incoming and outgoing HTTP connections to different services,
  506. # sometimes long running, it is a good idea to increase the default number
  507. # of sockets that Node will hold open.
  508. http = require('http')
  509. http.globalAgent.maxSockets = 300
  510. https = require('https')
  511. https.globalAgent.maxSockets = 300
  512. module.exports = settings