From 4566bf4ed8a5470cd08b23a5ef318deb51c8f26d Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 1 Apr 2019 12:09:11 +0200 Subject: [PATCH] drop support for various serverside config points --- config/config.example.js | 24 ------------------ rpc.js | 54 ++-------------------------------------- server.js | 1 - 3 files changed, 2 insertions(+), 77 deletions(-) diff --git a/config/config.example.js b/config/config.example.js index 78d275f92..01ac6677a 100644 --- a/config/config.example.js +++ b/config/config.example.js @@ -218,30 +218,6 @@ module.exports = { */ inactiveTime: 90, // days - /* some features may require that the server be able to schedule tasks - far into the future, such as: - > "three months from now, this channel should expire" - To disable these features, set 'enableTaskScheduling' to false - */ - enableTaskScheduling: true, - - /* Setting this value to anything other than true will cause file upload - * attempts to be rejected outright. - */ - enableUploads: true, - - /* If you have enabled file upload, you have the option of restricting it - * to a list of users identified by their public keys. If this value is set - * to true, your server will query a file (cryptpad/privileged.conf) when - * users connect via RPC. Only users whose public keys can be found within - * the file will be allowed to upload. - * - * privileged.conf uses '#' for line comments, and splits keys by newline. - * This is a temporary measure until a better quota system is in place. - * registered users' public keys can be found on the settings page. - */ - restrictUploads: false, - /* Max Upload Size (bytes) * this sets the maximum size of any one file uploaded to the server. * anything larger than this size will be rejected diff --git a/rpc.js b/rpc.js index 81227b97c..367dfb915 100644 --- a/rpc.js +++ b/rpc.js @@ -771,30 +771,6 @@ var resetUserPins = function (Env, publicKey, channelList, cb) { }); }; -var getPrivilegedUserList = function (cb) { // FIXME deprecate? - Fs.readFile('./privileged.conf', 'utf8', function (e, body) { - if (e) { - if (e.code === 'ENOENT') { - return void cb(void 0, []); - } - return void (e.code); - } - var list = body.split(/\n/) - .map(function (line) { - return line.replace(/#.*$/, '').trim(); - }) - .filter(function (x) { return x; }); - cb(void 0, list); - }); -}; - -var isPrivilegedUser = function (publicKey, cb) { // FIXME deprecate - getPrivilegedUserList(function (e, list) { - if (e) { return void cb(false); } - cb(list.indexOf(publicKey) !== -1); - }); -}; - var makeFileStream = function (root, id, cb) { var stub = id.slice(0, 2); var full = makeFilePath(root, id); @@ -1831,7 +1807,7 @@ RPC.create = function ( Respond('E_ACCESS_DENIED'); }; - var handleMessage = function (privileged) { + var handleMessage = function () { if (config.logRPC) { console.log(msg[0]); } switch (msg[0]) { case 'COOKIE': return void Respond(void 0); @@ -1913,15 +1889,12 @@ RPC.create = function ( if (e) { return void Respond(e); } Respond(void 0, "OK"); }); - // restricted to privileged users... case 'UPLOAD': - if (!privileged) { return deny(); } return void upload(Env, safeKey, msg[1], function (e, len) { WARN(e, len); Respond(e, len); }); case 'UPLOAD_STATUS': - if (!privileged) { return deny(); } var filesize = msg[1]; return void upload_status(Env, safeKey, msg[1], function (e, yes) { if (!e && !yes) { @@ -1933,19 +1906,16 @@ RPC.create = function ( Respond(e, yes); }); case 'UPLOAD_COMPLETE': - if (!privileged) { return deny(); } return void upload_complete(Env, safeKey, msg[1], function (e, hash) { WARN(e, hash); Respond(e, hash); }); case 'OWNED_UPLOAD_COMPLETE': - if (!privileged) { return deny(); } return void owned_upload_complete(Env, safeKey, msg[1], function (e, blobId) { WARN(e, blobId); Respond(e, blobId); }); case 'UPLOAD_CANCEL': - if (!privileged) { return deny(); } // msg[1] is fileSize // if we pass it here, we can start an upload right away without calling // UPLOAD_STATUS again @@ -1982,27 +1952,7 @@ RPC.create = function ( } }; - // reject uploads unless explicitly enabled - if (config.enableUploads !== true) { - return void handleMessage(false); - } - - // allow unrestricted uploads unless restrictUploads is true - if (config.restrictUploads !== true) { - return void handleMessage(true); - } - - // if session has not been authenticated, do so - var session = getSession(Sessions, safeKey); - if (typeof(session.privilege) !== 'boolean') { - return void isPrivilegedUser(publicKey, function (yes) { - session.privilege = yes; - handleMessage(yes); - }); - } - - // if authenticated, proceed - handleMessage(session.privilege); + handleMessage(true); }; var rpc = function ( diff --git a/server.js b/server.js index 5375f1148..1e9112be1 100644 --- a/server.js +++ b/server.js @@ -249,7 +249,6 @@ var historyKeeper; // Initialize tasks, then rpc, then store, then history keeper and then start the server var nt = nThen(function (w) { - if (!config.enableTaskScheduling) { return; } var Tasks = require("./storage/tasks"); console.log("loading task scheduler"); Tasks.create(config, w(function (e, tasks) {