Add user and permission system

Add users, roles and permissions and rework the authentication to use
separate user and slave tokens for control and slave connections
respectively.

Add commands for listing permissions, roles and users, and creating,
editing and deleting roles and users.
This commit is contained in:
Hornwitser committed 2020-06-15 16:47:15 +02:00
1 parent 2acf57d23d
commit cf6f2cb70a
20 files changed
+1511 -153

No files matched your search

+13 -12
View File
@@ -54,7 +54,7 @@ let slaveProcess;
let control;
let url = "https://localhost:4443/";
let token = jwt.sign({ id: "api" }, "TestSecretDoNotUse");
let controlToken = jwt.sign({ aud: "user", user: "test" }, "TestSecretDoNotUse");
let instancesDir = path.join("temp", "test", "instances");
let databaseDir = path.join("temp", "test", "databse");
let masterConfigPath = path.join("temp", "test", "master-integration.json");
@@ -71,6 +71,10 @@ async function sendRcon(instanceId, command) {
return response.result;
}
function getControl() {
return control;
}
function spawn(name, cmd, waitFor) {
return new Promise((resolve, reject) => {
console.log(cmd);
@@ -111,20 +115,18 @@ before(async function() {
await exec(`node master --config ${masterConfigPath} config set master.heartbeat_interval 0.25`);
await exec(`node master --config ${masterConfigPath} config set master.connector_shutdown_timeout 2`);
await exec(`node slave --config ${slaveConfigPath} config set slave.id 4`);
await exec(`node slave --config ${slaveConfigPath} config set slave.name slave`);
await exec(`node slave --config ${slaveConfigPath} config set slave.instances_directory ${instancesDir}`);
await exec(`node slave --config ${slaveConfigPath} config set slave.master_url "${url}"`);
await exec(`node slave --config ${slaveConfigPath} config set slave.master_token "${token}"`);
await exec(`node clusterctl --config ${controlConfigPath} control-config set control.master_url "https://localhost:4443/"`);
await exec(`node clusterctl --config ${controlConfigPath} control-config set control.master_token "${token}"`);
await exec(`node master --config ${masterConfigPath} bootstrap create-admin test`);
await exec(`node master --config ${masterConfigPath} bootstrap create-ctl-config test --output ${controlConfigPath}`);
masterProcess = await spawn("master:", `node master --config ${masterConfigPath} run`, "All plugins loaded");
await exec(`node clusterctl --config ${controlConfigPath} create-slave-config --id 4 --name slave --generate-token --output ${slaveConfigPath}`);
await exec(`node slave --config ${slaveConfigPath} config set slave.instances_directory ${instancesDir}`);
slaveProcess = await spawn("slave:", `node slave --config ${slaveConfigPath} run`, "SOCKET | received ready from master");
let controlConnector = new TestControlConnector(url, 2);
controlConnector.token = token;
controlConnector.token = controlToken;
control = new TestControl(controlConnector);
await controlConnector.connect();
});
@@ -157,10 +159,9 @@ module.exports = {
get,
exec,
sendRcon,
control,
getControl,
url,
token,
instancesDir,
databaseDir,
masterConfigPath,