How to Configure Dify Supabase Permissions
You set up dify supabase permissions by creating a custom database user with limited table grants. Then you give that new role to your AI app instead of the default admin login. Many teams rush this step and share the main project password with external tools. That broad role lets an AI workflow read or change every table in the project. A single bad prompt or workflow bug can then wipe out production rows. How dify supabase permissions work at the database level Every Supabase project starts
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.
You set up dify supabase permissions by creating a custom database user with limited table grants. Then you give that new role to your AI app instead of the default admin login. Many teams rush this step and share the main project password with external tools. That broad role lets an AI workflow read or change every table in the project. A single bad prompt or workflow bug can then wipe out production rows.
How dify supabase permissions work at the database level
Every Supabase project starts with a default postgres role that holds admin privileges. Supabase does not grant full superuser rights because those allow destructive database actions. Instead, the platform gives this default admin role extra rights for most daily tasks. The password you create at project setup belongs to this main postgres admin role. Queries you run in the project dashboard also run under this default admin role.
Supabase warns that you should never give this main password to an outside service. Instead, you should make a fresh database user for each tool you link. Each new project also includes built-in roles like anon, authenticated, service_role, and authenticator. When an AI workflow in Dify queries your database, it logs in with one user. That database user determines which schemas, tables, and rows the workflow can touch.
To lock this down, you create a dedicated role just for your AI workflows. You grant that role read rights only on the specific tables the app needs. If the app must save chat logs, you grant write rights on that single table. You leave all billing, user login, and internal settings tables off the grant list. This setup stops the AI tool from touching tables outside its assigned scope.
Why static database roles leave an operational gap
A custom database role solves the problem of which tables the AI app can reach. It blocks the tool from dropping tables or reading schemas it has no business using. This is a strong first step for any team running AI workflows on live data. Still, database grants only check who logs in at the start of a session.
AI Agent Permissions + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Once the session starts, the database trusts every query that uses those valid login details. A static role cannot inspect what individual statements or requests do while in flight. If an allowed table holds customer emails, phone numbers, or card numbers, queries return them. Static table grants also cannot require a human check before a specific update runs.
Teams also struggle to track which specific AI agent or user triggered a bad query. To the database log, every query from the app looks like the same static role. You need controls that inspect live queries and rewrite sensitive fields like national IDs in results.
Check every Postgres query on the wire
Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres. It runs beside your database and reads the Postgres wire protocol. Your apps and agents keep their login details and change only the host and port in the connection string their tool uses.
Before a query runs, hoop.dev guardrails check the statement by its effect, table, or pattern. They refuse bad deletes or drops with a real Postgres error. On the way back, hoop.dev data masking rewrites sensitive values in returned rows based on your rules. Every query and verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.
Frequently asked questions
Should I use the default postgres role for my Dify workflows?
No, the default postgres role has admin privileges across your entire project. Supabase advises creating a separate database user for every external service you use.
Does the default Supabase admin role have full Postgres superuser access?
No, Supabase withholds superuser status to prevent destructive actions on the underlying database server. The default postgres role gets admin rights with extra privileges for safe management tasks.
Why are table grants not enough to protect sensitive fields from AI apps?
Table grants allow or block access to whole tables when the app logs in. They do not rewrite emails, phone numbers, or card numbers inside allowed query results.
Related guides
In this post