All posts

Non-human identity for autonomous agents on Postgres

The ideal state is that every autonomous data‑processing agent talks to PostgreSQL with a non-human identity that is scoped to exactly what it needs, and the system records each statement it runs. In practice most teams hand a single service account password to every bot, script, or AI worker that needs to read or write data. The credential lives in environment files, CI pipelines, or shared vault entries. Because the same user appears on every connection, the database cannot tell whether a que

Free White Paper

Non-Human Identity Management + Single Sign-On (SSO): The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

The ideal state is that every autonomous data‑processing agent talks to PostgreSQL with a non-human identity that is scoped to exactly what it needs, and the system records each statement it runs.

In practice most teams hand a single service account password to every bot, script, or AI worker that needs to read or write data. The credential lives in environment files, CI pipelines, or shared vault entries. Because the same user appears on every connection, the database cannot tell whether a query came from a nightly batch job or an ad‑hoc analytics request. Auditors see a flood of statements attached to a generic account, and any accidental or malicious command is indistinguishable from legitimate work.

This blanket approach also defeats the principle of least privilege. An autonomous agent that only needs to read a reporting view ends up with write permissions on the entire schema. If the agent is compromised, the attacker inherits the same broad rights. The lack of per‑agent visibility means you cannot enforce policy, block dangerous statements, or require a human to approve a risky operation before it reaches the database.

Why non‑human identity matters for Postgres

Non‑human identity means that a machine or AI process authenticates with a unique, purpose‑built credential instead of reusing a generic service account. The credential is issued for a specific task, expires after a short window, and carries only the permissions required for that task. With this model, you can answer questions such as:

  • Which autonomous job read customer PII on a given day?
  • Did any script attempt a DROP TABLE, and was it blocked?
  • Can we automatically redact sensitive columns before they leave the database?

These answers require three things that the default shared‑credential model cannot provide: scoped identity, real‑time enforcement, and immutable evidence of what actually happened.

How hoop.dev enforces non‑human identity

hoop.dev sits on the network as a Layer 7 gateway that terminates the PostgreSQL wire protocol. Every connection from an autonomous agent is routed through this gateway instead of going directly to the database. Because the gateway is the only place the traffic passes, it becomes the enforcement point for all policy decisions.

When an agent presents an OIDC token, hoop.dev validates the token, extracts the identity claims, and maps those claims to a short‑lived database credential that has exactly the privileges required for the requested operation. The mapping is defined in policy, not in the application code, so developers do not need to manage passwords.

hoop.dev records each session, storing a line‑by‑line log of every SQL statement the agent executes. The log is tied to the unique non‑human identity, so you can later trace which autonomous job performed a specific query.

Continue reading? Get the full guide.

Non-Human Identity Management + Single Sign-On (SSO): Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

Before any statement reaches PostgreSQL, hoop.dev inspects the command. If the statement matches a guardrail rule, such as attempting to drop a table, alter a production schema, or export large volumes of data, hoop.dev blocks the command and returns an error to the caller. This prevents accidental or malicious damage at the moment it is attempted.

For queries that return rows containing sensitive columns, hoop.dev applies inline data masking. The gateway redacts or hashes the PII fields before the result set is sent back to the agent, ensuring that downstream processes never see raw sensitive data.

If a request crosses a risk threshold, like a bulk delete or an access to a high‑value table, hoop.dev initiates a just‑in‑time approval workflow. A designated human reviewer receives a concise request describing the operation and can grant or deny it in real time. Only after approval does hoop.dev forward the statement to PostgreSQL.

All of these enforcement outcomes, session recording, command blocking, inline masking, and JIT approval, exist because hoop.dev occupies the data path. Without the gateway, the database would have no visibility into who is issuing each statement, and the policies could not be applied.

Implementing the pattern

To adopt non‑human identity for autonomous agents on PostgreSQL, start by deploying the hoop.dev gateway inside the same network segment as the database. The official getting‑started guide walks you through a Docker Compose deployment that includes the network‑resident agent, OIDC configuration, and default guardrails.

Next, define identity‑to‑credential mappings in the policy store. Each autonomous service registers a unique client identifier with your identity provider, and you create a policy that grants that client only SELECT on the reporting schema, or INSERT on a staging table, for example. The mapping is enforced by hoop.dev at connection time.

Finally, enable the built‑in guardrails and masking rules that are relevant to your data model. The learning hub provides detailed explanations of each rule type and how to tailor them to your compliance needs.

Benefits at a glance

  • Every autonomous agent authenticates with a purpose‑built, short‑lived credential.
  • Scope‑exact permissions reduce blast radius of a compromised agent.
  • Command‑level audit logs tie each statement to the originating non‑human identity.
  • Inline masking protects sensitive columns without code changes.
  • Just‑in‑time approvals add a human check for high‑risk operations.
  • All enforcement happens in the data path, guaranteeing that policies cannot be bypassed.

FAQ

Do I need to change my existing PostgreSQL client code?

No. Agents continue to use standard PostgreSQL clients (psql, libpq, ORM libraries). The only change is the connection endpoint: point the client at the hoop.dev gateway instead of the database host.

How are credentials protected?

The gateway stores the database password or IAM token internally. Clients never receive the credential; they only present an OIDC token that hoop.dev validates.

Can I still run ad‑hoc queries from a developer console?

Yes. Developers use their own human identity, which is also processed by hoop.dev. The same guardrails, masking, and audit logging apply, giving a consistent security posture across humans and machines.

Ready to try it out? View the open‑source repository on GitHub and follow the getting‑started guide to deploy hoop.dev and start issuing non‑human identities for your autonomous PostgreSQL workloads.

Open source

Save the open-source gateway for agent data access

Hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.

Star and save the repo →More posts