Managing Supabase Postgres credentials in n8n workflows

Published
Length
3 min read

Luis Felipe Dias

All posts

n8n encrypts Supabase Postgres credentials. Supabase maps API keys to Postgres roles. These roles define what data a workflow can touch. The risk is that the credential controls who connects. Nothing checks what each statement does once the connection is open. How n8n handles Supabase credentials You add connection details when you use a Postgres node in n8n. n8n creates a random encryption key on first launch. It encrypts your credentials before saving them to its internal database. The Pos

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

n8n encrypts Supabase Postgres credentials. Supabase maps API keys to Postgres roles. These roles define what data a workflow can touch. The risk is that the credential controls who connects. Nothing checks what each statement does once the connection is open.

How n8n handles Supabase credentials

You add connection details when you use a Postgres node in n8n. n8n creates a random encryption key on first launch. It encrypts your credentials before saving them to its internal database.

The Postgres node can act as a tool for AI agents. The AI model fills in parameters automatically. It can even generate the SQL query itself. This helps with natural language queries. But the model generates the exact statement that runs against your database. n8n sanitizes values passed as query parameters to prevent injection. However, this sanitization does not apply to the statement structure. If the model writes a destructive query in the main query field, that structure remains unchecked.

How Supabase controls access

Supabase uses Postgres roles to manage permissions. An API key resolves to a specific role. A secret key resolves to the service_role. This role has elevated access and bypasses Row Level Security (RLS). A publishable key resolves to anon or authenticated based on user state. These roles are subject to RLS policies.

Supabase recommends creating a dedicated user for each service. The default postgres role has admin privileges. Sharing its password with n8n gives that tool broad control over the database. RLS policies restrict which rows a role sees. But they do not prevent a role with DELETE grants from removing data. This is true if the statement is valid and allowed by permissions.

What permissions and roles leave open

Database roles and RLS are necessary setup. They define the boundary of what is possible. But they do not inspect the intent of a specific statement. If your n8n workflow uses a role with SELECT and DELETE grants, the database executes a DELETE statement if it arrives. The permission check happens at the object level. It does not happen at the statement level.

This gap is critical when an AI agent is involved. An agent might generate a query that looks correct in isolation. But it may have unintended consequences in context. A static permission model cannot distinguish between a routine cleanup and a mistaken mass deletion. It only knows if the role is allowed to delete rows. It does not know if this specific deletion is safe.

Just-in-Time Access + Ephemeral Credentials: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Checking statements on the connection

hoop.dev addresses this gap. It runs as an open-source proxy next to your Supabase Postgres instance. It speaks the Postgres protocol directly. It reads every statement the n8n workflow sends. It also reads every result that comes back. It does not replace your Supabase roles or RLS. It sits in the path between the n8n node and the database.

You can define guardrails in hoop.dev. These guardrails refuse statements based on their effect. You can block any DELETE statement that lacks a WHERE clause. You can also refuse operations on specific tables entirely. When a statement is refused, hoop.dev returns a Postgres error. You define the message. The n8n workflow receives a clear reason for the failure. It does not get a silent drop or a generic permission error.

hoop.dev also handles data masking. If a query returns sensitive columns like email addresses, hoop.dev rewrites those values. It does this before the data reaches the n8n node. This happens in memory. The stored data in Supabase remains unchanged. The request itself is never modified. Only the response is filtered.

Getting started

Point the n8n Postgres node at the hoop.dev proxy. Do not point it at the direct Supabase database host. You only change the host and port in the connection string. The credentials remain the same. Supabase RLS still applies. You configure the proxy with your guardrails and masking rules. It starts checking every statement from that workflow.

hoop.dev records every statement and decision. It stores this in a per-resource audit trail. You get a log of what the n8n agent attempted. You see what was allowed and what was blocked. You can review this trail to understand agent behavior. You can tune your rules over time.

hoop.dev is open source and MIT licensed. You can read the source code and run the proxy locally. The Postgres setup docs cover configuration for Postgres-compatible instances. See the guardrails documentation for details on defining statement rules.

Frequently asked questions

Does hoop.dev replace Supabase Row Level Security?
No. RLS still controls which rows a role can access. hoop.dev adds a layer on top. It checks the statement itself before it reaches the database. It also masks values in the results. They work together. RLS defines the boundary. hoop.dev checks statements and filters output.

Can hoop.dev block an n8n agent from deleting all rows?
Yes. You can create a guardrail rule. This rule refuses DELETE statements without a WHERE clause. If the agent generates such a statement, hoop.dev blocks it. It returns an error to the n8n workflow. The database never receives the destructive command.

Does masking change the data in my Supabase database?
No. Data masking only rewrites values in the response. It does this for the client. The rows in your Supabase database remain exactly as they are. The n8n workflow sees the masked values. The underlying data is untouched.

The query runs. The emails stay hidden.