2 hours ago · Tech · 0 comments

Because I refuse to log in twiceI use ForwardAuth for most of my self-hosted services, as it’s much more convenient than configuring authentication for each application individually. n8n doesn’t support this out of the box, but we can leverage External Hooks to add this functionality. By using the EXTERNAL_HOOK_FILES environment variable, we can load a custom script to enable ForwardAuth. const fs = require("fs"); const { resolve } = require("path"); const n8nBasePath = "@N8N_BASE_PATH@"; const pnpmDir = resolve(n8nBasePath, "node_modules/.pnpm"); const routerDir = fs .readdirSync(pnpmDir) .find((dir) => dir.startsWith("router@")); const Layer = require( resolve(pnpmDir, routerDir, "node_modules/router/lib/layer"), ); const { issueCookie } = require( resolve(n8nBasePath, "packages/cli/dist/auth/jwt"), ); const ignoreAuthRegexp = /^\/(assets|healthz|webhook|rest\/oauth2-credential)/; module.exports = { n8n: { ready: [ async function({ app }, config) { const { stack } = app.router;…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.