How to Configure Dify Supabase Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a dify supabase audit log by creating a dedicated database role for your AI app and turning on statement logging. This approach tracks every query that Dify sends to your Supabase database. Many teams skip this step at first. They use the default admin role that comes with every new Supabase project. Supabase states you should never give the default password to an outside service. Instead, you should make a new user for every single service. When an AI tool uses broad admin rights, y

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 a dify supabase audit log by creating a dedicated database role for your AI app and turning on statement logging. This approach tracks every query that Dify sends to your Supabase database.

Many teams skip this step at first. They use the default admin role that comes with every new Supabase project. Supabase states you should never give the default password to an outside service. Instead, you should make a new user for every single service. When an AI tool uses broad admin rights, your logs mix human work with bot traffic. Worse, a bad prompt could trigger a query that reads or drops sensitive tables.

How a native dify supabase audit log works

Every new Supabase project comes with a default admin role and built-in roles. Queries that you run inside the Supabase dashboard execute under that default admin role. Those dashboard queries also carry a special source comment in the text. When you link Dify to your database, you should build a custom role first.

Start by making a fresh database user just for your Dify workflows. Grant this role read or write access only to the tables that Dify needs. Next, turn on database auditing in your project so Postgres records incoming statements. Now, every query from your AI workflows shows up under that single service role.

Your team can read the audit records to see when Dify queried a table. You can separate dashboard queries from AI app traffic by checking the role name. This setup forms the base of a working audit trail for your AI tools.

What native roles solve and where gaps remain

A dedicated database role solves the problem of who can log in. It stops your AI app from holding full admin privileges across your whole project. It also tags database logs with the service name instead of the default admin.

Still, native database roles only check who logs in at the start. They do not inspect what each statement does while it runs in flight. Once Dify logs in with its role, any query allowed by that role runs right away. If a workflow queries a user table, the database returns all matching rows.

Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native audit logs record the query text after the database runs it. They do not rewrite sensitive fields like emails, phone numbers, or card numbers before returning results. Also, all Dify users and workflows share that one database role. The database log shows the shared service role, not which team member triggered the run. Teams often need statement-level controls and field masking alongside native database logs.

Best practices for scoping AI database roles

Keep your AI database roles as small as possible from day one. Never share the default project password created at setup with an outside AI tool. Create separate roles if Dify uses your database for both app state and vector search.

Give the vector search role read access only to your document tables. Block that role from reading customer billing or private profile tables. Check your audit records each week to spot strange query patterns from your AI apps. If a workflow stops needing a table, remove that table permission right away. Pairing tight role permissions with clear audit logs keeps your data safe as AI usage grows.

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 Supabase admin role for Dify?

No, Supabase states you should never share the default admin password with outside services. Always create a dedicated database user with narrow table rights for Dify.

How do I tell dashboard queries apart from Dify queries?

Queries run in the Supabase dashboard use the default admin role and include a dashboard comment. When Dify uses its own role, your logs show that custom role name instead.

Does a database audit log stop Dify from reading sensitive columns?

No, an audit log only records queries that run against the database. To hide sensitive fields like emails or card numbers, you need a tool that rewrites results.

The query runs. The emails stay hidden.