summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/config/default.js3
-rw-r--r--lib/config/environment.js3
-rw-r--r--lib/config/index.js4
-rwxr-xr-xlib/response.js11
4 files changed, 16 insertions, 5 deletions
diff --git a/lib/config/default.js b/lib/config/default.js
index f4c45e3d..e7e2e4b3 100644
--- a/lib/config/default.js
+++ b/lib/config/default.js
@@ -94,5 +94,6 @@ module.exports = {
tlsca: undefined
},
email: true,
- allowemailregister: true
+ allowemailregister: true,
+ allowpdfexport: true
}
diff --git a/lib/config/environment.js b/lib/config/environment.js
index 40b7e09f..6f33d140 100644
--- a/lib/config/environment.js
+++ b/lib/config/environment.js
@@ -69,5 +69,6 @@ module.exports = {
tlsca: process.env.HMD_LDAP_TLS_CA
},
email: toBooleanConfig(process.env.HMD_EMAIL),
- allowemailregister: toBooleanConfig(process.env.HMD_ALLOW_EMAIL_REGISTER)
+ allowemailregister: toBooleanConfig(process.env.HMD_ALLOW_EMAIL_REGISTER),
+ allowpdfexport: toBooleanConfig(process.env.HMD_ALLOW_PDF_EXPORT)
}
diff --git a/lib/config/index.js b/lib/config/index.js
index bea5a6af..dfad28ed 100644
--- a/lib/config/index.js
+++ b/lib/config/index.js
@@ -1,3 +1,4 @@
+
'use strict'
const fs = require('fs')
@@ -90,6 +91,7 @@ config.isEmailEnable = config.email
config.isGitHubEnable = config.github.clientID && config.github.clientSecret
config.isGitLabEnable = config.gitlab.clientID && config.gitlab.clientSecret
config.isLDAPEnable = config.ldap.url
+config.isPDFExportEnable = config.allowpdfexport
// generate correct path
config.sslcapath = path.join(appRootPath, config.sslcapath)
@@ -106,7 +108,7 @@ config.errorpath = path.join(appRootPath, config.errorpath)
config.prettypath = path.join(appRootPath, config.prettypath)
config.slidepath = path.join(appRootPath, config.slidepath)
-// maek config readonly
+// make config readonly
config = deepFreeze(config)
module.exports = config
diff --git a/lib/response.js b/lib/response.js
index a22d1e70..9e39ffb5 100755
--- a/lib/response.js
+++ b/lib/response.js
@@ -69,6 +69,7 @@ function showIndex (req, res, next) {
ldap: config.isLDAPEnable,
email: config.isEmailEnable,
allowemailregister: config.allowemailregister,
+ allowpdfexport: config.allowpdfexport,
signin: req.isAuthenticated(),
infoMessage: req.flash('info'),
errorMessage: req.flash('error')
@@ -98,7 +99,8 @@ function responseHackMD (res, note) {
google: config.isGoogleEnable,
ldap: config.isLDAPEnable,
email: config.isEmailEnable,
- allowemailregister: config.allowemailregister
+ allowemailregister: config.allowemailregister,
+ allowpdfexport: config.allowpdfexport
})
}
@@ -382,7 +384,12 @@ function noteActions (req, res, next) {
actionInfo(req, res, note)
break
case 'pdf':
- actionPDF(req, res, note)
+ if (config.allowpdfexport) {
+ actionPDF(req, res, note)
+ } else {
+ logger.error('PDF export failed: Disabled by config. Set "allowpdfexport: true" to enable. Check the documentation for details')
+ response.errorForbidden(res)
+ }
break
case 'gist':
actionGist(req, res, note)