How to Configure Supabase Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a supabase audit log by enabling database extensions and creating dedicated roles. Then you route your team through separate database accounts so logs record who ran each query. Many teams skip this step at first. They share the default admin password across apps and engineers. When everyone shares one role, your logs show activity, but they cannot name the person behind a query. Overly broad roles also let a single mistake wipe out live tables. How the native supabase audit log and

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 supabase audit log by enabling database extensions and creating dedicated roles. Then you route your team through separate database accounts so logs record who ran each query. Many teams skip this step at first. They share the default admin password across apps and engineers. When everyone shares one role, your logs show activity, but they cannot name the person behind a query. Overly broad roles also let a single mistake wipe out live tables.

How the native supabase audit log and role setup works

Every project starts with a default postgres role. This role has admin rights, though the platform holds back full superuser rights to block destructive server actions. The password you pick when you create the project belongs to this default admin role. Queries that your team runs inside the web dashboard also run as this default admin role. Those dashboard queries add a short source comment to the query text.

To build a clean audit trail, you should not share the default admin password with outside services or staff. The platform docs advises creating a new database user for every service and person instead. Each project also comes with built-in roles for app traffic, such as the anon role for public requests. When you give each engineer and service a distinct role, the database log records which role ran a statement. You can then review the log storage to see when a role changed a table or read data.

What native logging solves and the gap it leaves open

Native roles and audit tables solve the basic tracking problem after a query finishes. They tell you which database role logged in and what statement ran against your schema. Giving each service its own user also makes it easier to revoke a key if a tool breaks. This setup works well for tracking routine app traffic and reviewing past events during an audit.

Still, native database roles and logs only record events after the query runs. Once an engineer logs in with an admin role, the database lets any permitted statement run right away. A role check at login cannot pause a risky drop statement or require peer approval in flight. Also, native logs do not mask sensitive fields in query results. If a developer queries a user table, raw emails, phone numbers, card numbers, and national IDs return in plain text. Native logs also group dashboard queries under the shared default admin role, which blurs who ran what.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Closing the gap for live database queries

To fix this, teams separate human database sessions from shared admin passwords. Every query should tie back to an individual identity from your team directory, not a shared role. High-risk statements should pause for peer review before they touch production rows. Result sets should also pass through field masking that rewrites emails, phone numbers, and card numbers before display. This gives your team clear logs and safe day-to-day database access.

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, inline in the Postgres wire protocol. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review. 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 refuse bad deletes or drops with a real Postgres error, or hold risky queries for approval. On the way back, hoop.dev data masking rewrites sensitive values in returned rows in memory, and every 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

Why do dashboard queries all show the same database role in logs?

Queries run inside the project dashboard execute under the default postgres admin role. The platform attaches a dashboard source comment to these queries, rather than running them as separate database users.

Does the default admin role have full Postgres superuser rights?

No, the default postgres role has admin rights, not full superuser rights. The platform blocks superuser access to prevent destructive server commands, while granting extra rights for common admin tasks.

Should we use the default project password for third-party tools?

No, you should never share the default postgres password with outside services unless you trust them completely. Instead, create a dedicated database user with narrow permissions for each service you set up.

The query runs. The emails stay hidden.