Many teams assume that protecting a service account’s password is enough to stop data exfiltration. The reality is that the identity that runs a workload, whether a CI job, an AI‑driven agent, or a scheduled batch process, can be the vector that carries data out of a database. When a non‑human identity connects directly to Postgres, it inherits the same unrestricted network path as a human user, and the platform often lacks any visibility into what that identity is doing.
How teams typically connect today
In most environments, a service account is created once, its credentials are baked into configuration files or environment variables, and the same secret is reused by every automation job that needs database access. The connection goes straight from the host where the job runs to the Postgres instance over the internal network. Because the gateway sits nowhere in that path, there is no place to enforce query‑level policies, mask column values, or record the exact statements that were executed. Auditors therefore see only the fact that the service account was used, not the content of the queries or the volume of data that left the system.
What non‑human identity changes, and what it leaves untouched
Introducing non‑human identities, such as short‑lived OIDC tokens for CI pipelines or dedicated AI agent profiles, is a step toward least‑privilege access. The token can be scoped to a single database role, limiting the commands that can be run. However, the request still travels directly to Postgres. Without an intervening control plane, the database sees the request as if it came from a trusted client. No inline masking occurs, no command is blocked, and no approval workflow can intervene before a bulk export runs. The core problem, lack of an enforceable data path, remains.
Why a Layer 7 gateway is the missing piece
Placing a Layer 7, protocol‑aware gateway between the non‑human identity and the Postgres server creates a single enforcement surface. The gateway inspects each SQL statement as it passes through, applies policy rules, and records the full session for later replay. Because the gateway holds the database credential, the client never sees it, eliminating credential leakage at the edge.
Setup: identity and token provisioning
First, define the non‑human identity in your identity provider (Okta, Azure AD, Google Workspace, etc.). Issue short‑lived OIDC tokens that are mapped to a specific Postgres role. The token proves who the request is, but it does not grant direct network access; the request must still be routed through the gateway.
The data path: the gateway as the only place enforcement can happen
When the client presents its token, the gateway validates it, extracts the group membership, and determines the allowed SQL actions. Every query, SELECT, INSERT, COPY, or pg_dump, passes through this point. The gateway can:
