PostgreSQL security and access control

Authentication, encryption and privilege design for self-hosted PostgreSQL, from pg_hba.conf and TLS to directory login and encryption at rest.

Writing a secure pg_hba.conf

Designing PostgreSQL client authentication rules: record order, hostssl versus host, narrowing addresses and databases, removing trust and md5 entries, separate rules for replication and admins, and reloading safely.

Configuring TLS for PostgreSQL connections

Encrypting client and replication traffic: server certificates, ssl_min_protocol_version, requiring hostssl, client sslmode verify-full, certificate rotation and connection poolers in the path.

PostgreSQL client certificate authentication

Using certificates instead of passwords for services and admins: the cert method, clientcert=verify-full, mapping certificate names to roles with pg_ident.conf, and running an internal CA.

PostgreSQL 18 OAuth authentication with Keycloak

Letting users sign in to PostgreSQL 18 with tokens from an OAuth provider such as Keycloak: the oauth pg_hba method, choosing or building a validator library, issuer matching rules, scopes and role mapping.

PostgreSQL roles and least privilege

Designing PostgreSQL roles so applications and people get only what they need: owner versus application roles, predefined roles such as pg_read_all_data and pg_maintain, default privileges, public schema permissions and removing superuser use.

PostgreSQL password policies and account lockout

What PostgreSQL does and does not enforce for passwords: the passwordcheck module, password expiry with VALID UNTIL, no built-in lockout after failed logins, and pushing policy to a directory or SSO instead.

Encryption at rest for PostgreSQL

Choosing how to encrypt PostgreSQL data on disk: file system or block device encryption, Percona pg_tde transparent data encryption and its key providers, encrypted backups, and the threats each option does and does not cover.

Column-level encryption with pgcrypto

Encrypting individual fields with pgcrypto: PGP symmetric and public-key functions, where keys live, the exposure of keys in queries and logs, effect on indexing and search, and when to encrypt in the application instead.

PostgreSQL security audit

What an outside PostgreSQL security review checks: version and patch level, pg_hba.conf and TLS, roles and privileges, extensions, logging and pgAudit, backups and encryption, and a ranked remediation list.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.