Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
commit
a5cf6732c5
@ -218,30 +218,6 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
inactiveTime: 90, // days
|
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)
|
/* Max Upload Size (bytes)
|
||||||
* this sets the maximum size of any one file uploaded to the server.
|
* this sets the maximum size of any one file uploaded to the server.
|
||||||
* anything larger than this size will be rejected
|
* anything larger than this size will be rejected
|
||||||
|
|||||||
58
rpc.js
58
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 makeFileStream = function (root, id, cb) {
|
||||||
var stub = id.slice(0, 2);
|
var stub = id.slice(0, 2);
|
||||||
var full = makeFilePath(root, id);
|
var full = makeFilePath(root, id);
|
||||||
@ -1827,11 +1803,7 @@ RPC.create = function (
|
|||||||
return void Respond('INVALID_MSG');
|
return void Respond('INVALID_MSG');
|
||||||
}
|
}
|
||||||
|
|
||||||
var deny = function () {
|
var handleMessage = function () {
|
||||||
Respond('E_ACCESS_DENIED');
|
|
||||||
};
|
|
||||||
|
|
||||||
var handleMessage = function (privileged) {
|
|
||||||
if (config.logRPC) { console.log(msg[0]); }
|
if (config.logRPC) { console.log(msg[0]); }
|
||||||
switch (msg[0]) {
|
switch (msg[0]) {
|
||||||
case 'COOKIE': return void Respond(void 0);
|
case 'COOKIE': return void Respond(void 0);
|
||||||
@ -1913,15 +1885,12 @@ RPC.create = function (
|
|||||||
if (e) { return void Respond(e); }
|
if (e) { return void Respond(e); }
|
||||||
Respond(void 0, "OK");
|
Respond(void 0, "OK");
|
||||||
});
|
});
|
||||||
// restricted to privileged users...
|
|
||||||
case 'UPLOAD':
|
case 'UPLOAD':
|
||||||
if (!privileged) { return deny(); }
|
|
||||||
return void upload(Env, safeKey, msg[1], function (e, len) {
|
return void upload(Env, safeKey, msg[1], function (e, len) {
|
||||||
WARN(e, len);
|
WARN(e, len);
|
||||||
Respond(e, len);
|
Respond(e, len);
|
||||||
});
|
});
|
||||||
case 'UPLOAD_STATUS':
|
case 'UPLOAD_STATUS':
|
||||||
if (!privileged) { return deny(); }
|
|
||||||
var filesize = msg[1];
|
var filesize = msg[1];
|
||||||
return void upload_status(Env, safeKey, msg[1], function (e, yes) {
|
return void upload_status(Env, safeKey, msg[1], function (e, yes) {
|
||||||
if (!e && !yes) {
|
if (!e && !yes) {
|
||||||
@ -1933,19 +1902,16 @@ RPC.create = function (
|
|||||||
Respond(e, yes);
|
Respond(e, yes);
|
||||||
});
|
});
|
||||||
case 'UPLOAD_COMPLETE':
|
case 'UPLOAD_COMPLETE':
|
||||||
if (!privileged) { return deny(); }
|
|
||||||
return void upload_complete(Env, safeKey, msg[1], function (e, hash) {
|
return void upload_complete(Env, safeKey, msg[1], function (e, hash) {
|
||||||
WARN(e, hash);
|
WARN(e, hash);
|
||||||
Respond(e, hash);
|
Respond(e, hash);
|
||||||
});
|
});
|
||||||
case 'OWNED_UPLOAD_COMPLETE':
|
case 'OWNED_UPLOAD_COMPLETE':
|
||||||
if (!privileged) { return deny(); }
|
|
||||||
return void owned_upload_complete(Env, safeKey, msg[1], function (e, blobId) {
|
return void owned_upload_complete(Env, safeKey, msg[1], function (e, blobId) {
|
||||||
WARN(e, blobId);
|
WARN(e, blobId);
|
||||||
Respond(e, blobId);
|
Respond(e, blobId);
|
||||||
});
|
});
|
||||||
case 'UPLOAD_CANCEL':
|
case 'UPLOAD_CANCEL':
|
||||||
if (!privileged) { return deny(); }
|
|
||||||
// msg[1] is fileSize
|
// msg[1] is fileSize
|
||||||
// if we pass it here, we can start an upload right away without calling
|
// if we pass it here, we can start an upload right away without calling
|
||||||
// UPLOAD_STATUS again
|
// UPLOAD_STATUS again
|
||||||
@ -1982,27 +1948,7 @@ RPC.create = function (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// reject uploads unless explicitly enabled
|
handleMessage(true);
|
||||||
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);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var rpc = function (
|
var rpc = function (
|
||||||
|
|||||||
@ -254,7 +254,6 @@ var historyKeeper;
|
|||||||
|
|
||||||
// Initialize tasks, then rpc, then store, then history keeper and then start the server
|
// Initialize tasks, then rpc, then store, then history keeper and then start the server
|
||||||
var nt = nThen(function (w) {
|
var nt = nThen(function (w) {
|
||||||
if (!config.enableTaskScheduling) { return; }
|
|
||||||
var Tasks = require("./storage/tasks");
|
var Tasks = require("./storage/tasks");
|
||||||
console.log("loading task scheduler");
|
console.log("loading task scheduler");
|
||||||
Tasks.create(config, w(function (e, tasks) {
|
Tasks.create(config, w(function (e, tasks) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user