From f4eae40c6b27238f2c6440e4ff7047e28e56446e Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 1 Oct 2020 15:44:24 -0400 Subject: [PATCH] webaccess: Check for read-only pad ID in `userCanModify` This currently isn't absolutely necessary because all current callers of `userCanModify` already check for a read-only pad ID themselves. However: * This adds defense in depth. * This makes it possible to simply replace the import handler's `allowAnyoneToImport` check with a call to `userCanModify`. --- src/node/hooks/express/webaccess.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node/hooks/express/webaccess.js b/src/node/hooks/express/webaccess.js index 64943dda..410fb4e5 100644 --- a/src/node/hooks/express/webaccess.js +++ b/src/node/hooks/express/webaccess.js @@ -3,6 +3,7 @@ const log4js = require('log4js'); const httpLogger = log4js.getLogger('http'); const settings = require('../../utils/Settings'); const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); +const readOnlyManager = require('../../db/ReadOnlyManager'); hooks.deprecationNotices.authFailure = 'use the authnFailure and authzFailure hooks instead'; @@ -31,6 +32,7 @@ exports.normalizeAuthzLevel = (level) => { }; exports.userCanModify = (padId, req) => { + if (readOnlyManager.isReadOnlyId(padId)) return false; if (!settings.requireAuthentication) return true; const {session: {user} = {}} = req; assert(user); // If authn required and user == null, the request should have already been denied.