mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Add bootstrap command to generate slave token (#389)
To simplify the standalone installation add command to create a slave token without having to start up the master server.
This commit is contained in:
1 parent
31f1099dc0
commit
cf1e333191
1 file changed
+8
@@ -22,6 +22,7 @@ const setBlocking = require("set-blocking");
|
|||||||
const yargs = require("yargs");
|
const yargs = require("yargs");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
const winston = require("winston");
|
const winston = require("winston");
|
||||||
|
const jwt = require("jsonwebtoken");
|
||||||
|
|
||||||
// homebrew modules
|
// homebrew modules
|
||||||
const libErrors = require("@clusterio/lib/errors");
|
const libErrors = require("@clusterio/lib/errors");
|
||||||
@@ -135,6 +136,10 @@ async function handleBootstrapCommand(args, masterConfig) {
|
|||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(user.createToken(masterConfig.get("master.auth_secret")));
|
console.log(user.createToken(masterConfig.get("master.auth_secret")));
|
||||||
|
|
||||||
|
} else if (subCommand === "generate-slave-token") {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(jwt.sign({ aud: "slave", slave: args.id }, masterConfig.get("master.auth_secret")));
|
||||||
|
|
||||||
} else if (subCommand === "create-ctl-config") {
|
} else if (subCommand === "create-ctl-config") {
|
||||||
let admin = userManager.users.get(args.name);
|
let admin = userManager.users.get(args.name);
|
||||||
if (!admin) {
|
if (!admin) {
|
||||||
@@ -198,6 +203,9 @@ async function initialize() {
|
|||||||
yargs
|
yargs
|
||||||
.command("create-admin <name>", "Create a cluster admin")
|
.command("create-admin <name>", "Create a cluster admin")
|
||||||
.command("generate-user-token <name>", "Generate authentication token for the given user")
|
.command("generate-user-token <name>", "Generate authentication token for the given user")
|
||||||
|
.command("generate-slave-token <id>", "Generate authentication token for the given slave", yargs => {
|
||||||
|
yargs.positional("id", { describe: "ID of the slave", type: "number" });
|
||||||
|
})
|
||||||
.command("create-ctl-config <name>", "Create clusterioctl config for the given user", yargs => {
|
.command("create-ctl-config <name>", "Create clusterioctl config for the given user", yargs => {
|
||||||
yargs.option("output", {
|
yargs.option("output", {
|
||||||
describe: "Path to output config (- for stdout)", type: "string",
|
describe: "Path to output config (- for stdout)", type: "string",
|
||||||
|
|||||||
Reference in new issue
Block a user