mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
express: Move static handlers to expressPreSession
This avoids the need to exempt the paths from authentication checks, and it eliminates unnecessary express-session state.
This commit is contained in:
parent
72f4ae444d
commit
649fbdccf5
10 changed files with 65 additions and 85 deletions
|
@ -9,23 +9,6 @@ const readOnlyManager = require('../../db/ReadOnlyManager');
|
|||
|
||||
hooks.deprecationNotices.authFailure = 'use the authnFailure and authzFailure hooks instead';
|
||||
|
||||
const staticPathsRE = new RegExp(`^/(?:${[
|
||||
'api(?:/.*)?',
|
||||
'favicon\\.ico',
|
||||
'ep/pad/connection-diagnostic-info',
|
||||
'javascript',
|
||||
'javascripts/.*',
|
||||
'jserror/?',
|
||||
'locales\\.json',
|
||||
'locales/.*',
|
||||
'rest/.*',
|
||||
'pluginfw/.*',
|
||||
'robots.txt',
|
||||
'static/.*',
|
||||
'stats/?',
|
||||
'tests/frontend(?:/.*)?',
|
||||
].join('|')})$`);
|
||||
|
||||
// Promisified wrapper around hooks.aCallFirst.
|
||||
const aCallFirst = (hookName, context, pred = null) => new Promise((resolve, reject) => {
|
||||
hooks.aCallFirst(hookName, context, (err, r) => err != null ? reject(err) : resolve(r), pred);
|
||||
|
@ -90,7 +73,6 @@ const preAuthorize = async (req, res, next) => {
|
|||
return;
|
||||
}
|
||||
if (locals.skip) return;
|
||||
if (staticPathsRE.test(req.path)) results.push(true);
|
||||
if (requireAdmin) {
|
||||
// Filter out all 'true' entries to prevent plugin authors from accidentally granting admin
|
||||
// privileges to the general public.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue