mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Move user token signing to UserManager
Only the controller has access to the secret needed to sign user tokens so it makes sense for the user signing code to live in the controller. This saves about 20ms on the time ctl takes to start up due to lib no longer needing to import jsonwebtoken.
This commit is contained in:
1 parent
6af25e085c
commit
a5c7eb3a27
7 files changed
+20
-21
No files matched your search
@@ -130,7 +130,7 @@ async function handleBootstrapCommand(args, controllerConfig) {
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(user.createToken(controllerConfig.get("controller.auth_secret")));
|
||||
console.log(userManager.signUserToken(user.name));
|
||||
|
||||
} else if (subCommand === "generate-host-token") {
|
||||
// eslint-disable-next-line no-console
|
||||
@@ -151,7 +151,8 @@ async function handleBootstrapCommand(args, controllerConfig) {
|
||||
|
||||
controlConfig.set("control.controller_url", Controller.calculateControllerUrl(controllerConfig));
|
||||
controlConfig.set(
|
||||
"control.controller_token", admin.createToken(controllerConfig.get("controller.auth_secret"))
|
||||
"control.controller_token",
|
||||
userManager.signUserToken(admin.name),
|
||||
);
|
||||
|
||||
let content = JSON.stringify(controlConfig.serialize(), null, 4);
|
||||
|
||||
Reference in new issue
Block a user