From c084ed03e476098037ce7cae469bbb7594823991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 18 Jul 2024 18:02:58 +0200 Subject: [PATCH] remove the external hook --- docker-compose.yml | 2 -- n8n/hooks.js | 50 ---------------------------------------------- 2 files changed, 52 deletions(-) delete mode 100644 n8n/hooks.js diff --git a/docker-compose.yml b/docker-compose.yml index 86aae96..07803e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,6 @@ x-n8n: &service-n8n - N8N_PERSONALIZATION_ENABLED=false - N8N_ENCRYPTION_KEY - N8N_USER_MANAGEMENT_JWT_SECRET - - EXTERNAL_HOOK_FILES=/hooks.js links: - postgres @@ -71,7 +70,6 @@ services: - 5678:5678 volumes: - n8n_storage:/home/node/.n8n - - ./n8n/hooks.js:/hooks.js - ./n8n/backup:/backup depends_on: postgres: diff --git a/n8n/hooks.js b/n8n/hooks.js deleted file mode 100644 index 2ff4025..0000000 --- a/n8n/hooks.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * A hook that disables the user management and uses owner for all requests - */ -const { dirname, resolve } = require("path"); -const Layer = require("express/lib/router/layer"); - -const n8nDir = dirname(require.resolve("n8n")); -const { AuthService } = require(resolve(n8nDir, "auth/auth.service")); - -async function disableUmHook({ app }, config) { - await this.dbCollections.Settings.update( - { key: "userManagement.isInstanceOwnerSetUp" }, - { value: JSON.stringify(true) } - ); - - config.set("userManagement.isInstanceOwnerSetUp", true); - - const owner = await this.dbCollections.User.findOne({ - where: { role: "global:owner" }, - }); - - owner.email = "demo@n8n.io"; - owner.firstName = "Demo"; - owner.lastName = "User"; - - await this.dbCollections.User.save(owner); - - AuthService.prototype.resolveJwt = () => owner; - - const { stack } = app._router; - stack.unshift( - new Layer( - "/", - { - strict: false, - end: false, - }, - async (req, res, next) => { - req.cookies = { "n8n-auth": "fake" }; - next(); - } - ) - ); -} - -module.exports = { - n8n: { - ready: [disableUmHook], - }, -};