How to Configure Postgres Proxy
You set up a postgres proxy by placing a routing node between users and databases. This node takes client traffic and forwards it to your backend server using shared roles. Teams often start by setting up group roles on the database server itself. When permissions are too broad, any user can read sensitive rows or change schema objects. Putting a proxy in front helps teams manage who logs in from one central place. How a postgres proxy works with native database roles A database system manage
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 postgres proxy by placing a routing node between users and databases. This node takes client traffic and forwards it to your backend server using shared roles. Teams often start by setting up group roles on the database server itself. When permissions are too broad, any user can read sensitive rows or change schema objects. Putting a proxy in front helps teams manage who logs in from one central place.
How a postgres proxy works with native database roles
A database system manages access through roles and object privileges. When teams grow, admins create group roles to hold specific table permissions. Individual users then join these group roles to get the access they need. By default, a special group called PUBLIC gives every role basic rights on the system. This includes the right to log in to a database and run functions.
In PostgreSQL 15 and newer versions, regular users cannot create new objects in the public schema. Older versions allowed this by default, so admins had to revoke that right from PUBLIC. To allow data reading, admins grant the read privilege on a table or view. You can also grant this read privilege on specific columns of a table. Note that this same read privilege also lets a user export table data out.
A routing proxy sits on the network path in front of these native role rules. Instead of giving every user a direct network path, the team points tools at the proxy. The proxy checks the user and opens a session to the database using a backend role. This setup keeps database network ports hidden from general user machines. It also lets admins rotate database keys in one spot without breaking developer workflows.
What native roles solve and the gap they leave open
Native roles and a basic network proxy solve the first step of database security. They control which person or app can open a session to a database instance. Group roles also make it easier to assign read rights across many tables at once. If an admin revokes default rights from PUBLIC, random roles cannot run unwanted functions. Column grants even let teams pick which fields a specific role is allowed to query.
Still, static roles and basic proxies only check rules when the session starts. Once a user logs in, the setup does not inspect individual commands in flight. If a role has read access to a customer table, every query returns raw data. A developer running a check gets real emails, phone numbers, card numbers, and national IDs. Maintaining separate column grants for every single table quickly becomes hard to track across schemas.
Database Proxy (ProxySQL, PgBouncer) + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Also, a basic routing proxy does not pause risky write statements for human review. If an engineer needs to fix a broken row, they must use a write role. Once they have that role, nothing stops an accidental delete across the whole table. Native database logs only record what happened after the query has already finished running.
Adding query checks and field masking at the proxy layer
To close this gap, teams use a proxy that understands the database wire protocol. Instead of just passing raw network packets, the proxy reads each statement before sending it. This allows the team to keep a small set of simple roles on the database. The proxy then applies fine rules based on who is running the command right now.
When a query returns rows, data masking rules rewrite matched fields in the results. Sensitive fields like emails, phone numbers, and card numbers get replaced before reaching the screen. When an engineer sends a write command, the proxy can hold the query for approval. Another team member reviews the exact statement in chat and approves it to run. This gives teams tight control over live queries without managing thousands of database grants.
Add query and result controls beside Postgres
Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your Postgres. For every plain or prepared query an agent or human runs against production, hoop.dev decides to pass, mask, block, or escalate it for review.
When a tool or agent sends SQL, hoop.dev Postgres controls block banned statements before execution or hold risky ones for human approval via an AI Analyzer you configure. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.
Frequently asked questions
Does a postgres proxy replace native database roles?
No, the proxy works alongside your existing database roles. You still use a small set of backend roles while the proxy handles user checks.
How does PostgreSQL handle default permissions for new roles?
Every new role gets the rights assigned to the special PUBLIC group by default. This includes the right to log in, create temporary tables, and run functions.
Can native read privileges restrict specific columns?
Yes, an admin can grant the read privilege on specific columns of a table. Still, managing column grants across many tables and users takes a lot of manual work.
Related guides
In this post