feat(editor): Add Env vars for auth cookie samesite and csp headers #13855
+31
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Advanced deployment scenarios like embedding n8n requires customization to security headers. Manipulating headers can be achieved using proxies like nginx or traefik, but it's hard to learn and too demanding for running quick POCs. To embed n8n's UI in an iframe you need to be able to customize the following headers:
samesite=none
andsecure
. We already have the env var N8N_SECURE_COOKIE for the secure attribute. This adds theN8N_SAMESITE_COOKIE
env var.X-Frame-Options: SAMEORIGIN
, so that the page can only be displayed if all ancestor frames have the same origin to the page itself. That does not work for iFrames, since the embedding page will most likely have a different origin (subdomains don't work). This PR adds the env varN8N_CONTENT_SECURITY_POLICY
to set CSP headers as json object definition according to helmet.js. With CSP headers we can setframe-ancestors: ["http://example.com"]
, to specify what parent source may embed a page. The frame-ancestors directive overrules the X-Frame-Options header and is the preferred way to speficy embedding page origins.Notes:
contentSecurityPolicy.useDefaults=false
to force engineers to always define their owndefault-src
when defining csp headers, e.g.default-src 'self'
.Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)