webaccess: Use single quotes everywhere

This commit is contained in:
Richard Hansen 2020-08-26 20:57:05 -04:00 committed by John McLear
parent 9011207a37
commit 726101d6a8

View file

@ -1,6 +1,6 @@
var express = require('express'); var express = require('express');
var log4js = require('log4js'); var log4js = require('log4js');
var httpLogger = log4js.getLogger("http"); var httpLogger = log4js.getLogger('http');
var settings = require('../../utils/Settings'); var settings = require('../../utils/Settings');
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var ueberStore = require('../../db/SessionStore'); var ueberStore = require('../../db/SessionStore');
@ -27,13 +27,13 @@ exports.basicAuth = function(req, res, next) {
if (req.session && req.session.user && req.session.user.is_admin) return cb(true); if (req.session && req.session.user && req.session.user.is_admin) return cb(true);
hooks.aCallFirst("authorize", {req: req, res: res, next: next, resource: req.path}, hookResultMangle(cb)); hooks.aCallFirst('authorize', {req: req, res: res, next: next, resource: req.path}, hookResultMangle(cb));
}; };
var authenticate = function(cb) { var authenticate = function(cb) {
// If auth headers are present use them to authenticate... // If auth headers are present use them to authenticate...
if (req.headers.authorization && req.headers.authorization.search('Basic ') === 0) { if (req.headers.authorization && req.headers.authorization.search('Basic ') === 0) {
var userpass = Buffer.from(req.headers.authorization.split(' ')[1], 'base64').toString().split(":"); var userpass = Buffer.from(req.headers.authorization.split(' ')[1], 'base64').toString().split(':');
var username = userpass.shift(); var username = userpass.shift();
var password = userpass.join(':'); var password = userpass.join(':');
var fallback = function(success) { var fallback = function(success) {
@ -51,15 +51,15 @@ exports.basicAuth = function(req, res, next) {
req.session.user = settings.users[username]; req.session.user = settings.users[username];
return cb(true); return cb(true);
}; };
return hooks.aCallFirst("authenticate", {req: req, res: res, next: next, username: username, password: password}, hookResultMangle(fallback)); return hooks.aCallFirst('authenticate', {req: req, res: res, next: next, username: username, password: password}, hookResultMangle(fallback));
} }
hooks.aCallFirst("authenticate", {req: req, res: res, next: next}, hookResultMangle(cb)); hooks.aCallFirst('authenticate', {req: req, res: res, next: next}, hookResultMangle(cb));
}; };
/* Authentication OR authorization failed. */ /* Authentication OR authorization failed. */
var failure = function() { var failure = function() {
return hooks.aCallFirst("authFailure", {req: req, res: res, next: next}, hookResultMangle(function(ok) { return hooks.aCallFirst('authFailure', {req: req, res: res, next: next}, hookResultMangle(function(ok) {
if (ok) return; if (ok) return;
/* No plugin handler for invalid auth. Return Auth required /* No plugin handler for invalid auth. Return Auth required
* Headers, delayed for 1 second, if authentication failed * Headers, delayed for 1 second, if authentication failed
@ -115,7 +115,7 @@ exports.expressConfigure = function(hook_name, args, cb) {
// If the log level specified in the config file is WARN or ERROR the application server never starts listening to requests as reported in issue #158. // If the log level specified in the config file is WARN or ERROR the application server never starts listening to requests as reported in issue #158.
// Not installing the log4js connect logger when the log level has a higher severity than INFO since it would not log at that level anyway. // Not installing the log4js connect logger when the log level has a higher severity than INFO since it would not log at that level anyway.
if (!(settings.loglevel === "WARN" || settings.loglevel == "ERROR")) if (!(settings.loglevel === 'WARN' || settings.loglevel == 'ERROR'))
args.app.use(log4js.connectLogger(httpLogger, {level: log4js.levels.DEBUG, format: ':status, :method :url'})); args.app.use(log4js.connectLogger(httpLogger, {level: log4js.levels.DEBUG, format: ':status, :method :url'}));
/* Do not let express create the session, so that we can retain a /* Do not let express create the session, so that we can retain a
@ -129,9 +129,9 @@ exports.expressConfigure = function(hook_name, args, cb) {
} }
if (settings.ssl) { if (settings.ssl) {
var sameSite = "Strict"; var sameSite = 'Strict';
} else { } else {
var sameSite = "Lax"; var sameSite = 'Lax';
} }
args.app.sessionStore = exports.sessionStore; args.app.sessionStore = exports.sessionStore;