mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-05-09 06:06:13 +02:00
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`.
This commit is contained in:
parent
9a6f286441
commit
f4eae40c6b
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user