Allow pre-rename host tokens

Ease migration to the new controller/host naming by allowing tokens
issued to the slave naming to be authenticated by the controller.
This commit is contained in:
Hornwitser committed 2023-02-23 00:12:48 +01:00
1 parent b4259f59cf
commit 10528fbb90
1 file changed
+4 -2
+4 -2
View File
@@ -216,10 +216,12 @@ ${err.stack}`
let tokenPayload = jwt.verify(
data.token,
Buffer.from(this.controller.config.get("controller.auth_secret"), "base64"),
{ audience: "host" }
// migrate: allow pre-rename tokens issued to hosts before alpha-14
{ audience: ["host", "slave"] }
);
if (tokenPayload.host !== data.id) {
// migrate: allow pre-rename tokens issued to hosts before alpha-14
if ((tokenPayload.host !== undefined ? tokenPayload.host : tokenPayload.slave) !== data.id) {
throw new Error("missmatched host id");
}