2021-07-07 07:39:45 -04:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
|
|
|
no-cond-assign,
|
|
|
|
no-dupe-keys,
|
|
|
|
no-unused-vars,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2021-07-07 07:39:42 -04:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS205: Consider reworking code to avoid use of IIFEs
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2022-01-31 09:00:15 -05:00
|
|
|
let redisConfig, siteUrl
|
2021-07-07 07:43:33 -04:00
|
|
|
let e
|
|
|
|
const Path = require('path')
|
2021-07-07 07:39:42 -04:00
|
|
|
|
|
|
|
// These credentials are used for authenticating api requests
|
|
|
|
// between services that may need to go over public channels
|
2024-02-06 04:34:15 -05:00
|
|
|
const httpAuthUser = process.env.WEB_API_USER
|
2021-07-07 07:43:33 -04:00
|
|
|
const httpAuthPass = process.env.WEB_API_PASSWORD
|
|
|
|
const httpAuthUsers = {}
|
2024-02-06 04:34:15 -05:00
|
|
|
if (httpAuthUser && httpAuthPass) {
|
|
|
|
httpAuthUsers[httpAuthUser] = httpAuthPass
|
|
|
|
}
|
2021-07-07 07:43:33 -04:00
|
|
|
|
|
|
|
const parse = function (option) {
|
|
|
|
if (option != null) {
|
|
|
|
try {
|
|
|
|
const opt = JSON.parse(option)
|
|
|
|
return opt
|
|
|
|
} catch (err) {
|
|
|
|
throw new Error(`problem parsing ${option}, invalid JSON`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
|
2021-07-07 07:43:33 -04:00
|
|
|
const parseIntOrFail = function (value) {
|
|
|
|
const parsedValue = parseInt(value, 10)
|
|
|
|
if (isNaN(parsedValue)) {
|
|
|
|
throw new Error(`'${value}' is an invalid integer`)
|
|
|
|
}
|
|
|
|
return parsedValue
|
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
|
2024-02-09 10:52:24 -05:00
|
|
|
const DATA_DIR = '/var/lib/overleaf/data'
|
|
|
|
const TMP_DIR = '/var/lib/overleaf/tmp'
|
2021-07-07 07:43:33 -04:00
|
|
|
|
|
|
|
const settings = {
|
|
|
|
clsi: {
|
|
|
|
optimiseInDocker: process.env.OPTIMISE_PDF === 'true',
|
|
|
|
},
|
|
|
|
|
|
|
|
brandPrefix: '',
|
|
|
|
|
|
|
|
allowAnonymousReadAndWriteSharing:
|
2024-02-13 05:02:09 -05:00
|
|
|
process.env.OVERLEAF_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING === 'true',
|
2021-07-07 07:43:33 -04:00
|
|
|
|
|
|
|
// Databases
|
|
|
|
// ---------
|
|
|
|
|
2024-02-06 04:34:15 -05:00
|
|
|
// Overleaf Community Edition's main persistent data store is MongoDB (http://www.mongodb.org/)
|
2021-07-07 07:43:33 -04:00
|
|
|
// Documentation about the URL connection string format can be found at:
|
|
|
|
//
|
|
|
|
// http://docs.mongodb.org/manual/reference/connection-string/
|
|
|
|
//
|
|
|
|
// The following works out of the box with Mongo's default settings:
|
|
|
|
mongo: {
|
2024-01-29 06:41:12 -05:00
|
|
|
url: process.env.OVERLEAF_MONGO_URL || 'mongodb://dockerhost/sharelatex',
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
|
2024-02-06 04:34:15 -05:00
|
|
|
// Redis is used in Overleaf Community Edition for high volume queries, like real-time
|
2021-07-07 07:43:33 -04:00
|
|
|
// editing, and session management.
|
|
|
|
//
|
|
|
|
// The following config will work with Redis's default settings:
|
|
|
|
redis: {
|
|
|
|
web: (redisConfig = {
|
2024-01-29 06:41:12 -05:00
|
|
|
host: process.env.OVERLEAF_REDIS_HOST || 'dockerhost',
|
|
|
|
port: process.env.OVERLEAF_REDIS_PORT || '6379',
|
|
|
|
password: process.env.OVERLEAF_REDIS_PASS || undefined,
|
2021-07-07 07:43:33 -04:00
|
|
|
key_schema: {
|
|
|
|
// document-updater
|
|
|
|
blockingKey({ doc_id }) {
|
|
|
|
return `Blocking:${doc_id}`
|
|
|
|
},
|
|
|
|
docLines({ doc_id }) {
|
|
|
|
return `doclines:${doc_id}`
|
|
|
|
},
|
|
|
|
docOps({ doc_id }) {
|
|
|
|
return `DocOps:${doc_id}`
|
|
|
|
},
|
|
|
|
docVersion({ doc_id }) {
|
|
|
|
return `DocVersion:${doc_id}`
|
|
|
|
},
|
|
|
|
docHash({ doc_id }) {
|
|
|
|
return `DocHash:${doc_id}`
|
|
|
|
},
|
|
|
|
projectKey({ doc_id }) {
|
|
|
|
return `ProjectId:${doc_id}`
|
|
|
|
},
|
|
|
|
docsInProject({ project_id }) {
|
|
|
|
return `DocsIn:${project_id}`
|
|
|
|
},
|
|
|
|
ranges({ doc_id }) {
|
|
|
|
return `Ranges:${doc_id}`
|
|
|
|
},
|
|
|
|
// document-updater:realtime
|
|
|
|
pendingUpdates({ doc_id }) {
|
|
|
|
return `PendingUpdates:${doc_id}`
|
|
|
|
},
|
|
|
|
// document-updater:history
|
|
|
|
uncompressedHistoryOps({ doc_id }) {
|
|
|
|
return `UncompressedHistoryOps:${doc_id}`
|
|
|
|
},
|
|
|
|
docsWithHistoryOps({ project_id }) {
|
|
|
|
return `DocsWithHistoryOps:${project_id}`
|
|
|
|
},
|
|
|
|
// document-updater:lock
|
|
|
|
blockingKey({ doc_id }) {
|
|
|
|
return `Blocking:${doc_id}`
|
|
|
|
},
|
|
|
|
// realtime
|
|
|
|
clientsInProject({ project_id }) {
|
|
|
|
return `clients_in_project:${project_id}`
|
|
|
|
},
|
|
|
|
connectedUser({ project_id, client_id }) {
|
|
|
|
return `connected_user:${project_id}:${client_id}`
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
fairy: redisConfig,
|
2023-05-25 04:32:59 -04:00
|
|
|
// document-updater
|
2021-07-07 07:43:33 -04:00
|
|
|
realtime: redisConfig,
|
|
|
|
documentupdater: redisConfig,
|
|
|
|
lock: redisConfig,
|
|
|
|
history: redisConfig,
|
|
|
|
websessions: redisConfig,
|
|
|
|
api: redisConfig,
|
|
|
|
pubsub: redisConfig,
|
|
|
|
project_history: redisConfig,
|
2023-01-20 06:06:26 -05:00
|
|
|
|
|
|
|
project_history_migration: {
|
|
|
|
host: redisConfig.host,
|
|
|
|
port: redisConfig.port,
|
|
|
|
password: redisConfig.password,
|
|
|
|
maxRetriesPerRequest: parseInt(
|
|
|
|
process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
|
|
|
|
),
|
|
|
|
key_schema: {
|
|
|
|
projectHistoryOps({ projectId }) {
|
|
|
|
return `ProjectHistory:Ops:{${projectId}}` // NOTE: the extra braces are intentional
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
// Local disk caching
|
|
|
|
// ------------------
|
|
|
|
path: {
|
|
|
|
// If we ever need to write something to disk (e.g. incoming requests
|
|
|
|
// that need processing but may be too big for memory), then write
|
|
|
|
// them to disk here:
|
|
|
|
dumpFolder: Path.join(TMP_DIR, 'dumpFolder'),
|
|
|
|
// Where to write uploads before they are processed
|
|
|
|
uploadFolder: Path.join(TMP_DIR, 'uploads'),
|
2023-02-02 10:12:52 -05:00
|
|
|
// Where to write intermediate file for full project history migration
|
|
|
|
projectHistories: Path.join(TMP_DIR, 'projectHistories'),
|
2021-07-07 07:43:33 -04:00
|
|
|
// Where to write the project to disk before running LaTeX on it
|
|
|
|
compilesDir: Path.join(DATA_DIR, 'compiles'),
|
|
|
|
// Where to cache downloaded URLs for the CLSI
|
|
|
|
clsiCacheDir: Path.join(DATA_DIR, 'cache'),
|
|
|
|
// Where to write the output files to disk after running LaTeX
|
|
|
|
outputDir: Path.join(DATA_DIR, 'output'),
|
|
|
|
},
|
|
|
|
|
|
|
|
// Server Config
|
|
|
|
// -------------
|
|
|
|
|
2024-02-06 04:34:15 -05:00
|
|
|
// Where your instance of Overleaf Community Edition can be found publicly. This is used
|
2021-07-07 07:43:33 -04:00
|
|
|
// when emails are sent out and in generated links:
|
2024-01-29 06:41:12 -05:00
|
|
|
siteUrl: (siteUrl = process.env.OVERLEAF_SITE_URL || 'http://localhost'),
|
2021-07-07 07:43:33 -04:00
|
|
|
|
2022-10-18 06:41:19 -04:00
|
|
|
// Status page URL as displayed on the maintenance/500 pages.
|
2024-01-29 06:41:12 -05:00
|
|
|
statusPageUrl: process.env.OVERLEAF_STATUS_PAGE_URL,
|
2022-10-18 06:41:19 -04:00
|
|
|
|
2024-02-06 04:34:15 -05:00
|
|
|
// The name this is used to describe your Overleaf Community Edition Installation
|
2024-01-29 06:41:12 -05:00
|
|
|
appName: process.env.OVERLEAF_APP_NAME || 'Overleaf Community Edition',
|
2021-07-07 07:43:33 -04:00
|
|
|
|
|
|
|
restrictInvitesToExistingAccounts:
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_RESTRICT_INVITES_TO_EXISTING_ACCOUNTS === 'true',
|
2021-07-07 07:43:33 -04:00
|
|
|
|
|
|
|
nav: {
|
|
|
|
title:
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_NAV_TITLE ||
|
|
|
|
process.env.OVERLEAF_APP_NAME ||
|
2024-02-06 04:34:15 -05:00
|
|
|
'Overleaf Community Edition',
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
// The email address which users will be directed to as the main point of
|
2024-02-06 04:34:15 -05:00
|
|
|
// contact for this installation of Overleaf Community Edition.
|
2024-01-29 06:41:12 -05:00
|
|
|
adminEmail: process.env.OVERLEAF_ADMIN_EMAIL || 'placeholder@example.com',
|
2021-07-07 07:43:33 -04:00
|
|
|
|
|
|
|
// If provided, a sessionSecret is used to sign cookies so that they cannot be
|
|
|
|
// spoofed. This is recommended.
|
|
|
|
security: {
|
|
|
|
sessionSecret:
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_SESSION_SECRET || process.env.CRYPTO_RANDOM,
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
// These credentials are used for authenticating api requests
|
|
|
|
// between services that may need to go over public channels
|
|
|
|
httpAuthUsers,
|
|
|
|
|
|
|
|
// Should javascript assets be served minified or not.
|
|
|
|
useMinifiedJs: true,
|
|
|
|
|
|
|
|
// Should static assets be sent with a header to tell the browser to cache
|
|
|
|
// them. This should be false in development where changes are being made,
|
|
|
|
// but should be set to true in production.
|
|
|
|
cacheStaticAssets: true,
|
|
|
|
|
2024-02-06 04:34:15 -05:00
|
|
|
// If you are running Overleaf Community Edition over https, set this to true to send the
|
2021-07-07 07:43:33 -04:00
|
|
|
// cookie with a secure flag (recommended).
|
2024-01-29 06:41:12 -05:00
|
|
|
secureCookie: process.env.OVERLEAF_SECURE_COOKIE != null,
|
2021-07-07 07:43:33 -04:00
|
|
|
|
2024-02-06 04:34:15 -05:00
|
|
|
// If you are running Overleaf Community Edition behind a proxy (like Apache, Nginx, etc)
|
2021-07-07 07:43:33 -04:00
|
|
|
// then set this to true to allow it to correctly detect the forwarded IP
|
|
|
|
// address and http/https protocol information.
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
behindProxy: process.env.OVERLEAF_BEHIND_PROXY || false,
|
2024-02-07 10:21:17 -05:00
|
|
|
trustedProxyIps: process.env.OVERLEAF_TRUSTED_PROXY_IPS,
|
2021-07-07 07:43:33 -04:00
|
|
|
|
2023-09-28 05:38:24 -04:00
|
|
|
// The amount of time, in milliseconds, until the (rolling) cookie session expires
|
|
|
|
cookieSessionLength: parseInt(
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_COOKIE_SESSION_LENGTH || 5 * 24 * 60 * 60 * 1000, // default 5 days
|
2023-09-28 05:38:24 -04:00
|
|
|
10
|
|
|
|
),
|
|
|
|
|
2024-01-19 03:33:27 -05:00
|
|
|
redisLockTTLSeconds: parseInt(
|
2024-02-07 10:21:17 -05:00
|
|
|
process.env.OVERLEAF_REDIS_LOCK_TTL_SECONDS || '60',
|
2024-01-19 03:33:27 -05:00
|
|
|
10
|
|
|
|
),
|
|
|
|
|
2021-07-07 07:43:33 -04:00
|
|
|
i18n: {
|
|
|
|
subdomainLang: {
|
|
|
|
www: {
|
2024-02-07 10:21:17 -05:00
|
|
|
lngCode: process.env.OVERLEAF_SITE_LANGUAGE || 'en',
|
2021-07-07 07:43:33 -04:00
|
|
|
url: siteUrl,
|
|
|
|
},
|
|
|
|
},
|
2024-02-07 10:21:17 -05:00
|
|
|
defaultLng: process.env.OVERLEAF_SITE_LANGUAGE || 'en',
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
currentImageName: process.env.TEX_LIVE_DOCKER_IMAGE,
|
|
|
|
|
|
|
|
apis: {
|
|
|
|
web: {
|
|
|
|
url: 'http://localhost:3000',
|
|
|
|
user: httpAuthUser,
|
|
|
|
pass: httpAuthPass,
|
|
|
|
},
|
2023-01-20 06:06:26 -05:00
|
|
|
project_history: {
|
|
|
|
sendProjectStructureOps: true,
|
|
|
|
url: 'http://localhost:3054',
|
|
|
|
},
|
|
|
|
v1_history: {
|
2023-04-04 08:14:56 -04:00
|
|
|
url: process.env.V1_HISTORY_URL || 'http://localhost:3100/api',
|
2023-01-20 06:06:26 -05:00
|
|
|
user: 'staging',
|
|
|
|
pass: process.env.STAGING_PASSWORD,
|
2023-10-24 09:28:37 -04:00
|
|
|
requestTimeout: parseInt(
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_HISTORY_V1_HTTP_REQUEST_TIMEOUT || '300000', // default is 5min
|
2023-10-24 09:28:37 -04:00
|
|
|
10
|
|
|
|
),
|
2023-02-10 04:07:10 -05:00
|
|
|
},
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
references: {},
|
|
|
|
notifications: undefined,
|
|
|
|
|
|
|
|
defaultFeatures: {
|
|
|
|
collaborators: -1,
|
|
|
|
dropbox: true,
|
|
|
|
versioning: true,
|
|
|
|
compileTimeout: parseIntOrFail(process.env.COMPILE_TIMEOUT || 180),
|
|
|
|
compileGroup: 'standard',
|
|
|
|
trackChanges: true,
|
|
|
|
templates: true,
|
|
|
|
references: true,
|
|
|
|
},
|
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
|
2021-07-07 07:39:45 -04:00
|
|
|
// # OPTIONAL CONFIGURABLE SETTINGS
|
2021-07-07 07:39:42 -04:00
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_LEFT_FOOTER != null) {
|
2021-07-07 07:43:33 -04:00
|
|
|
try {
|
2024-01-29 06:41:12 -05:00
|
|
|
settings.nav.left_footer = JSON.parse(process.env.OVERLEAF_LEFT_FOOTER)
|
2021-07-07 07:43:33 -04:00
|
|
|
} catch (error) {
|
|
|
|
e = error
|
2024-01-29 06:41:12 -05:00
|
|
|
console.error('could not parse OVERLEAF_LEFT_FOOTER, not valid JSON')
|
2021-07-07 07:43:33 -04:00
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_RIGHT_FOOTER != null) {
|
|
|
|
settings.nav.right_footer = process.env.OVERLEAF_RIGHT_FOOTER
|
2021-07-07 07:43:33 -04:00
|
|
|
try {
|
2024-01-29 06:41:12 -05:00
|
|
|
settings.nav.right_footer = JSON.parse(process.env.OVERLEAF_RIGHT_FOOTER)
|
2021-07-07 07:43:33 -04:00
|
|
|
} catch (error1) {
|
|
|
|
e = error1
|
2024-01-29 06:41:12 -05:00
|
|
|
console.error('could not parse OVERLEAF_RIGHT_FOOTER, not valid JSON')
|
2021-07-07 07:43:33 -04:00
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_HEADER_IMAGE_URL != null) {
|
|
|
|
settings.nav.custom_logo = process.env.OVERLEAF_HEADER_IMAGE_URL
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_HEADER_EXTRAS != null) {
|
2021-07-07 07:43:33 -04:00
|
|
|
try {
|
2024-01-29 06:41:12 -05:00
|
|
|
settings.nav.header_extras = JSON.parse(process.env.OVERLEAF_HEADER_EXTRAS)
|
2021-07-07 07:43:33 -04:00
|
|
|
} catch (error2) {
|
|
|
|
e = error2
|
2024-01-29 06:41:12 -05:00
|
|
|
console.error('could not parse OVERLEAF_HEADER_EXTRAS, not valid JSON')
|
2021-07-07 07:43:33 -04:00
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sending Email
|
|
|
|
// -------------
|
|
|
|
//
|
|
|
|
// You must configure a mail server to be able to send invite emails from
|
2024-02-06 04:34:15 -05:00
|
|
|
// Overleaf Community Edition. The config settings are passed to nodemailer. See the nodemailer
|
2021-07-07 07:39:42 -04:00
|
|
|
// documentation for available options:
|
|
|
|
//
|
|
|
|
// http://www.nodemailer.com/docs/transports
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_EMAIL_FROM_ADDRESS != null) {
|
2021-07-07 07:43:33 -04:00
|
|
|
settings.email = {
|
2024-01-29 06:41:12 -05:00
|
|
|
fromAddress: process.env.OVERLEAF_EMAIL_FROM_ADDRESS,
|
|
|
|
replyTo: process.env.OVERLEAF_EMAIL_REPLY_TO || '',
|
|
|
|
driver: process.env.OVERLEAF_EMAIL_DRIVER,
|
2021-07-07 07:43:33 -04:00
|
|
|
parameters: {
|
|
|
|
// AWS Creds
|
2024-01-29 06:41:12 -05:00
|
|
|
AWSAccessKeyID: process.env.OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID,
|
|
|
|
AWSSecretKey: process.env.OVERLEAF_EMAIL_AWS_SES_SECRET_KEY,
|
2021-07-07 07:43:33 -04:00
|
|
|
|
|
|
|
// SMTP Creds
|
2024-01-29 06:41:12 -05:00
|
|
|
host: process.env.OVERLEAF_EMAIL_SMTP_HOST,
|
|
|
|
port: process.env.OVERLEAF_EMAIL_SMTP_PORT,
|
|
|
|
secure: parse(process.env.OVERLEAF_EMAIL_SMTP_SECURE),
|
|
|
|
ignoreTLS: parse(process.env.OVERLEAF_EMAIL_SMTP_IGNORE_TLS),
|
|
|
|
name: process.env.OVERLEAF_EMAIL_SMTP_NAME,
|
|
|
|
logger: process.env.OVERLEAF_EMAIL_SMTP_LOGGER === 'true',
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
textEncoding: process.env.OVERLEAF_EMAIL_TEXT_ENCODING,
|
2021-07-07 07:43:33 -04:00
|
|
|
template: {
|
2024-01-29 06:41:12 -05:00
|
|
|
customFooter: process.env.OVERLEAF_CUSTOM_EMAIL_FOOTER,
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_EMAIL_AWS_SES_REGION != null) {
|
|
|
|
settings.email.parameters.region = process.env.OVERLEAF_EMAIL_AWS_SES_REGION
|
2021-07-07 07:43:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_EMAIL_SMTP_USER != null ||
|
|
|
|
process.env.OVERLEAF_EMAIL_SMTP_PASS != null
|
2021-07-07 07:43:33 -04:00
|
|
|
) {
|
|
|
|
settings.email.parameters.auth = {
|
2024-01-29 06:41:12 -05:00
|
|
|
user: process.env.OVERLEAF_EMAIL_SMTP_USER,
|
|
|
|
pass: process.env.OVERLEAF_EMAIL_SMTP_PASS,
|
2021-07-07 07:43:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH != null) {
|
2021-07-07 07:43:33 -04:00
|
|
|
settings.email.parameters.tls = {
|
|
|
|
rejectUnauthorized: parse(
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH
|
2021-07-07 07:43:33 -04:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
2017-01-06 06:28:32 -05:00
|
|
|
|
2021-07-07 07:39:42 -04:00
|
|
|
// i18n
|
2024-02-07 10:21:17 -05:00
|
|
|
if (process.env.OVERLEAF_LANG_DOMAIN_MAPPING != null) {
|
2021-07-07 07:43:33 -04:00
|
|
|
settings.i18n.subdomainLang = parse(
|
2024-02-07 10:21:17 -05:00
|
|
|
process.env.OVERLEAF_LANG_DOMAIN_MAPPING
|
2021-07-07 07:43:33 -04:00
|
|
|
)
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
2016-04-06 12:07:59 -04:00
|
|
|
|
2021-07-07 07:39:42 -04:00
|
|
|
// Password Settings
|
|
|
|
// -----------
|
|
|
|
// These restrict the passwords users can use when registering
|
|
|
|
// opts are from http://antelle.github.io/passfield
|
2021-07-07 07:43:33 -04:00
|
|
|
if (
|
2024-02-07 10:21:17 -05:00
|
|
|
process.env.OVERLEAF_PASSWORD_VALIDATION_PATTERN ||
|
|
|
|
process.env.OVERLEAF_PASSWORD_VALIDATION_MIN_LENGTH ||
|
|
|
|
process.env.OVERLEAF_PASSWORD_VALIDATION_MAX_LENGTH
|
2021-07-07 07:43:33 -04:00
|
|
|
) {
|
|
|
|
settings.passwordStrengthOptions = {
|
2024-02-07 10:21:17 -05:00
|
|
|
pattern: process.env.OVERLEAF_PASSWORD_VALIDATION_PATTERN || 'aA$3',
|
2021-07-07 07:43:33 -04:00
|
|
|
length: {
|
2024-02-07 10:21:17 -05:00
|
|
|
min: process.env.OVERLEAF_PASSWORD_VALIDATION_MIN_LENGTH || 8,
|
|
|
|
max: process.env.OVERLEAF_PASSWORD_VALIDATION_MAX_LENGTH || 72,
|
2021-07-07 07:43:33 -04:00
|
|
|
},
|
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
2016-04-06 12:07:59 -04:00
|
|
|
|
2021-07-07 07:39:45 -04:00
|
|
|
// ######################
|
2024-02-06 04:34:15 -05:00
|
|
|
// Overleaf Server Pro
|
2021-07-07 07:39:45 -04:00
|
|
|
// ######################
|
2016-05-23 06:30:25 -04:00
|
|
|
|
2024-01-29 09:39:52 -05:00
|
|
|
if (parse(process.env.OVERLEAF_IS_SERVER_PRO) === true) {
|
2021-07-07 07:43:33 -04:00
|
|
|
settings.bypassPercentageRollouts = true
|
|
|
|
settings.apis.references = { url: 'http://localhost:3040' }
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
2016-05-23 06:30:25 -04:00
|
|
|
|
2021-07-07 07:39:42 -04:00
|
|
|
// Compiler
|
|
|
|
// --------
|
2021-07-07 07:43:33 -04:00
|
|
|
if (process.env.SANDBOXED_COMPILES === 'true') {
|
|
|
|
settings.clsi = {
|
|
|
|
dockerRunner: true,
|
|
|
|
docker: {
|
|
|
|
image: process.env.TEX_LIVE_DOCKER_IMAGE,
|
|
|
|
env: {
|
|
|
|
HOME: '/tmp',
|
|
|
|
PATH:
|
|
|
|
process.env.COMPILER_PATH ||
|
|
|
|
'/usr/local/texlive/2015/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
|
|
|
},
|
|
|
|
user: 'www-data',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.path == null) {
|
|
|
|
settings.path = {}
|
|
|
|
}
|
|
|
|
settings.path.synctexBaseDir = () => '/compile'
|
|
|
|
if (process.env.SANDBOXED_COMPILES_SIBLING_CONTAINERS === 'true') {
|
|
|
|
console.log('Using sibling containers for sandboxed compiles')
|
|
|
|
if (process.env.SANDBOXED_COMPILES_HOST_DIR) {
|
|
|
|
settings.path.sandboxedCompilesHostDir =
|
|
|
|
process.env.SANDBOXED_COMPILES_HOST_DIR
|
|
|
|
} else {
|
|
|
|
console.error(
|
|
|
|
'Sibling containers, but SANDBOXED_COMPILES_HOST_DIR not set'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Templates
|
|
|
|
// ---------
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_TEMPLATES_USER_ID) {
|
2021-07-07 07:43:33 -04:00
|
|
|
settings.templates = {
|
|
|
|
mountPointUrl: '/templates',
|
2024-01-29 06:41:12 -05:00
|
|
|
user_id: process.env.OVERLEAF_TEMPLATES_USER_ID,
|
2021-07-07 07:43:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
settings.templateLinks = parse(
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS
|
2021-07-07 07:43:33 -04:00
|
|
|
)
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
2016-05-23 06:30:25 -04:00
|
|
|
|
2021-07-07 07:39:42 -04:00
|
|
|
// /Learn
|
|
|
|
// -------
|
2024-01-29 06:41:12 -05:00
|
|
|
if (process.env.OVERLEAF_PROXY_LEARN != null) {
|
|
|
|
settings.proxyLearn = parse(process.env.OVERLEAF_PROXY_LEARN)
|
2022-04-07 05:50:33 -04:00
|
|
|
if (settings.proxyLearn) {
|
2023-02-10 04:07:10 -05:00
|
|
|
settings.nav.header_extras = [
|
|
|
|
{
|
|
|
|
url: '/learn',
|
|
|
|
text: 'documentation',
|
|
|
|
},
|
|
|
|
].concat(settings.nav.header_extras || [])
|
2022-04-07 05:50:33 -04:00
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
2016-04-06 12:07:59 -04:00
|
|
|
|
2021-07-07 07:39:42 -04:00
|
|
|
// /References
|
|
|
|
// -----------
|
2024-02-07 10:21:17 -05:00
|
|
|
if (process.env.OVERLEAF_ELASTICSEARCH_URL != null) {
|
2021-07-07 07:43:33 -04:00
|
|
|
settings.references.elasticsearch = {
|
2024-02-07 10:21:17 -05:00
|
|
|
host: process.env.OVERLEAF_ELASTICSEARCH_URL,
|
2021-07-07 07:43:33 -04:00
|
|
|
}
|
2021-07-07 07:39:42 -04:00
|
|
|
}
|
|
|
|
|
2023-02-10 04:07:10 -05:00
|
|
|
// filestore
|
2024-01-29 06:41:12 -05:00
|
|
|
switch (process.env.OVERLEAF_FILESTORE_BACKEND) {
|
2023-02-10 04:07:10 -05:00
|
|
|
case 's3':
|
|
|
|
settings.filestore = {
|
|
|
|
backend: 's3',
|
|
|
|
stores: {
|
2024-01-29 06:41:12 -05:00
|
|
|
user_files: process.env.OVERLEAF_FILESTORE_USER_FILES_BUCKET_NAME,
|
2023-02-10 04:07:10 -05:00
|
|
|
template_files:
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_FILESTORE_TEMPLATE_FILES_BUCKET_NAME,
|
2023-02-10 04:07:10 -05:00
|
|
|
},
|
|
|
|
s3: {
|
|
|
|
key:
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_FILESTORE_S3_ACCESS_KEY_ID ||
|
2023-02-10 04:07:10 -05:00
|
|
|
process.env.AWS_ACCESS_KEY_ID,
|
|
|
|
secret:
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_FILESTORE_S3_SECRET_ACCESS_KEY ||
|
2023-02-10 10:57:34 -05:00
|
|
|
process.env.AWS_SECRET_ACCESS_KEY,
|
2024-01-29 06:41:12 -05:00
|
|
|
endpoint: process.env.OVERLEAF_FILESTORE_S3_ENDPOINT,
|
|
|
|
pathStyle: process.env.OVERLEAF_FILESTORE_S3_PATH_STYLE === 'true',
|
2023-02-10 04:07:10 -05:00
|
|
|
region:
|
2024-01-29 06:41:12 -05:00
|
|
|
process.env.OVERLEAF_FILESTORE_S3_REGION ||
|
2023-02-10 04:07:10 -05:00
|
|
|
process.env.AWS_DEFAULT_REGION,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
settings.filestore = {
|
|
|
|
backend: 'fs',
|
|
|
|
stores: {
|
|
|
|
user_files: Path.join(DATA_DIR, 'user_files'),
|
|
|
|
template_files: Path.join(DATA_DIR, 'template_files'),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 07:39:42 -04:00
|
|
|
// With lots of incoming and outgoing HTTP connections to different services,
|
|
|
|
// sometimes long running, it is a good idea to increase the default number
|
|
|
|
// of sockets that Node will hold open.
|
2021-07-07 07:43:33 -04:00
|
|
|
const http = require('http')
|
|
|
|
http.globalAgent.maxSockets = 300
|
|
|
|
const https = require('https')
|
|
|
|
https.globalAgent.maxSockets = 300
|
2021-07-07 07:39:42 -04:00
|
|
|
|
2021-07-07 07:43:33 -04:00
|
|
|
module.exports = settings
|