Skip to content

Lock down n8n webhooks with shared-secret header auth - #7

Draft
Frezertade wants to merge 2 commits into
mainfrom
claude/etsy-webhook-auth-K3YLR
Draft

Frezertade wants to merge 2 commits into
mainfrom
claude/etsy-webhook-auth-K3YLR

Conversation

@Frezertade

Copy link
Copy Markdown
Owner

Summary

Closes the open-webhook security gap. Every data-mutating webhook now requires X-Webhook-Secret: <N8N_WEBHOOK_SECRET> on every call; n8n returns 401 otherwise.

Locked down (require auth)

  • 01 - AI Listing Generator
  • 02 - AI Visual Studio
  • 03 - AI Ads Studio
  • 04a - Etsy Connect (start OAuth)
  • 05 - Etsy Listing Publish
  • 07 - POD Route Order

Public exemptions

  • 04 - Etsy OAuth Callback — Etsy is the caller; can't send custom headers. State + PKCE provide CSRF protection.
  • 02b - Mockup View — used by <img src="…">; browsers can't send custom headers on image requests.

Internal call updates

  • wf 06 - Etsy Order Syncwf 07 ("Dispatch POD") now sends X-Webhook-Secret.
  • wf 03 - Ads Studiowf 02 (visual gen, optional) now sends X-Webhook-Secret.

Workflow 04a behavior change

Switched from rendering an HTML "Authorise on Etsy" page to returning JSON { auth_url, state, shop_name }. Without this, the ToolJet Shops tab button could no longer reach 04a (browsers can't send custom headers on window.open). The flow is now: button → REST query (with the auth header) → onSuccess opens the returned auth_url in a new tab.

ToolJet

  • New workspace constant N8N_WEBHOOK_SECRET (operator sets to match n8n's env var).
  • n8n_api datasource sends X-Webhook-Secret on every call.
  • Shops tab "Authorise on Etsy" button uses the new query → redirect pattern.

Setup (one-time, after merge)

  1. openssl rand -hex 32 → set N8N_WEBHOOK_SECRET in .env; docker compose restart n8n.
  2. n8n UI → Credentials → New → Header Auth: name n8n Webhook Secret, header X-Webhook-Secret, value = the secret.
  3. ToolJet UI → Workspace constants → N8N_WEBHOOK_SECRET = same value.

Test plan

  • curl http://localhost:5678/webhook/listing-generate -d '{}' -H 'content-type: application/json' returns 401
  • Same call with -H "x-webhook-secret: $N8N_WEBHOOK_SECRET" succeeds
  • In ToolJet AI Tools tab, Generate button still works end-to-end
  • In ToolJet Shops tab, "Authorise on Etsy" opens an etsy.com tab with a valid auth_url
  • Etsy redirects back to /webhook/etsy-oauth-callback with no auth header (public exemption) and the shop upserts
  • <img src="http://localhost:5678/webhook/mockup-view?id=1"> still renders (public exemption)
  • Trigger wf 06 manually; confirm new orders dispatch to wf 07 successfully (internal call carries the header)

https://claude.ai/code/session_019vtZjGwcACasFeauRYTQnj


Generated by Claude Code

Workflows 01, 02, 03, 04a, 05, 07 now require
'X-Webhook-Secret: <N8N_WEBHOOK_SECRET>' on every call. n8n's native
'headerAuth' returns 401 when the header is missing or wrong. Public
exemptions: 04 (Etsy OAuth callback — Etsy can't send custom headers)
and 02b (mockup image proxy — browser <img> can't send headers either).

Internal cross-workflow calls were updated to send the header:
  - wf 06 'Dispatch POD' → wf 07
  - wf 03 'Validate + Visual' → wf 02

Workflow 04a switches from rendering an HTML page to returning JSON
{auth_url, state, shop_name}. The ToolJet Shops tab now has a query
that hits /webhook/etsy-connect with the auth header, then the button's
onSuccess redirects window.open(auth_url). This sidesteps the issue of
window.open being unable to send the secret header.

ToolJet's n8n_api datasource sends X-Webhook-Secret on every call,
sourced from a new N8N_WEBHOOK_SECRET workspace constant. README
documents the one-time credential setup.

https://claude.ai/code/session_019vtZjGwcACasFeauRYTQnj
@gitguardian

gitguardian Bot commented May 4, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
32453737 Triggered Generic High Entropy Secret 9036391 tooljet-apps/etsy_dashboard.json View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

GitGuardian flagged 'set_to_match_n8n_env' as a high-entropy generic
secret — it's a placeholder, not a real value, but tripping the
detector is noise. Empty string signals 'operator MUST set this' without
any entropy, and the _note already explains where to source it from.

https://claude.ai/code/session_019vtZjGwcACasFeauRYTQnj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants